mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-02 21:30:29 +00:00
clear unused part of configuration buffer
This commit is contained in:
parent
86bc96b7e6
commit
56e7f86bc4
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user