if (fd == -1)
return -1;
- rd = read(fd, buf, 50);
+ rd = read(fd, buf, sizeof(buf));
if (rd == -1) {
sys_errmsg("cannot read \"%s\"", file);
goto out_error;
}
- if (rd == 50) {
+ if (rd == sizeof(buf)) {
errmsg("contents of \"%s\" is too long", file);
errno = EINVAL;
goto out_error;
}
+ buf[rd] = '\0';
if (sscanf(buf, "%lld\n", value) != 1) {
errmsg("cannot read integer from \"%s\"\n", file);
sys_errmsg("cannot read \"%s\"", file);
goto out_error;
}
+ ((char *)buf)[rd] = '\0';
/* Make sure all data is read */
tmp1 = read(fd, &tmp, 1);
{
struct ubi_set_prop_req r;
- memset(&r, sizeof(struct ubi_set_prop_req), '\0');
+ memset(&r, 0, sizeof(struct ubi_set_prop_req));
r.property = property;
r.value = value;