if (cxt->has_hctl)
goto done;
- len = sysfs_readlink(cxt, "device", buf, sizeof(buf));
+ len = sysfs_readlink(cxt, "device", buf, sizeof(buf) - 1);
if (len < 0)
return len;
int len;
if ((len = readlink_at(dirfd(dir), dirname,
- d->d_name, path, sizeof(path))) < 0)
+ d->d_name, path, sizeof(path) - 1)) < 0)
return 0;
path[len] = '\0';
return NULL;
}
- len = readlink(path, buf, buf_size);
+ len = readlink(path, buf, buf_size - 1);
if (len < 0) {
warn(_("%s: failed to read link"), path);
return NULL;
continue;
if ((len = readlink_at(fd, path, dp->d_name,
- sym, sizeof(path))) < 1)
+ sym, sizeof(sym) - 1)) < 1)
goto out;
*size = sb.st_size;
memcpy(chain + len, SUBSYSTEM_LINKNAME, sizeof(SUBSYSTEM_LINKNAME));
/* try if subsystem symlink exists */
- sz = readlink(chain, buf, bufsz);
+ sz = readlink(chain, buf, bufsz - 1);
/* remove last subsystem from chain */
chain[len] = '\0';