diff options
author | Karel Zak | 2019-06-06 11:09:17 +0200 |
---|---|---|
committer | Karel Zak | 2019-06-17 15:47:39 +0200 |
commit | e3188dd90a4cd51723fefdcea8c3b82a6e7afc29 (patch) | |
tree | b16a1a09f1fd4382edd8426a8a16911b59f8cae5 /lib/path.c | |
parent | wdctl: default to /dev/watchdog0 (diff) | |
download | kernel-qcow2-util-linux-e3188dd90a4cd51723fefdcea8c3b82a6e7afc29.tar.gz kernel-qcow2-util-linux-e3188dd90a4cd51723fefdcea8c3b82a6e7afc29.tar.xz kernel-qcow2-util-linux-e3188dd90a4cd51723fefdcea8c3b82a6e7afc29.zip |
lib/path: make sure ul_path_read_buffer() derminate result
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/path.c')
-rw-r--r-- | lib/path.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/path.c b/lib/path.c index f7fd19592..8dce1da40 100644 --- a/lib/path.c +++ b/lib/path.c @@ -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; } |