clear unused part of configuration buffer

This commit is contained in:
Laurent Vivier 2008-07-28 09:59:27 +00:00
parent 86bc96b7e6
commit 56e7f86bc4

View File

@ -21,6 +21,7 @@ int emile_second_set_configuration(int fd, int8_t *configuration)
int size; int size;
int len; int len;
off_t offset; off_t offset;
char *buf;
if (configuration == NULL) if (configuration == NULL)
return EEMILE_CANNOT_READ_SECOND; return EEMILE_CANNOT_READ_SECOND;
@ -45,9 +46,14 @@ int emile_second_set_configuration(int fd, int8_t *configuration)
if (len > size) if (len > size)
return EEMILE_INVALID_SECOND; return EEMILE_INVALID_SECOND;
ret = write(fd, configuration, len); buf = malloc(size);
memset(buf, 0, size);
memcpy(buf, configuration, len);
ret = write(fd, buf, size);
if (ret != len) if (ret != len)
return EEMILE_CANNOT_WRITE_SECOND; return EEMILE_CANNOT_WRITE_SECOND;
free(buf);
return 0; return 0;
} }