summaryrefslogtreecommitdiffstats
path: root/lib/path.c
diff options
context:
space:
mode:
authorKarel Zak2019-06-17 15:48:28 +0200
committerKarel Zak2019-06-17 15:48:28 +0200
commitbddcf5b81673b4cc362b36bac3caaeabb1738fcc (patch)
treeeb375002908b685c325282469a47bdbc1ff86681 /lib/path.c
parentinclude/closestream: avoid close more than once (diff)
parentwdctl; read from /sys if necessary (diff)
downloadkernel-qcow2-util-linux-bddcf5b81673b4cc362b36bac3caaeabb1738fcc.tar.gz
kernel-qcow2-util-linux-bddcf5b81673b4cc362b36bac3caaeabb1738fcc.tar.xz
kernel-qcow2-util-linux-bddcf5b81673b4cc362b36bac3caaeabb1738fcc.zip
Merge branch 'topic/wdctl'
Diffstat (limited to 'lib/path.c')
-rw-r--r--lib/path.c5
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;
}