lib/path: make sure ul_path_read_buffer() derminate result

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-06-06 11:09:17 +02:00
parent 8c8df42146
commit e3188dd90a
1 changed files with 3 additions and 2 deletions

View File

@ -610,9 +610,10 @@ int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char
/* Remove tailing newline (usual in sysfs) */
if (rc > 0 && *(buf + rc - 1) == '\n')
--rc;
buf[--rc] = '\0';
else
buf[rc - 1] = '\0';
buf[rc] = '\0';
return rc;
}