diff options
author | Karel Zak | 2018-05-15 14:11:38 +0200 |
---|---|---|
committer | Karel Zak | 2018-06-21 13:07:46 +0200 |
commit | d5878cabe6e9df5a9dacbbd637f53784d0b19928 (patch) | |
tree | 49eaf784b21f0c1deb207fdf6360191fa2adfc35 /lib | |
parent | lib/path lib/sysfs: add debug (diff) | |
download | kernel-qcow2-util-linux-d5878cabe6e9df5a9dacbbd637f53784d0b19928.tar.gz kernel-qcow2-util-linux-d5878cabe6e9df5a9dacbbd637f53784d0b19928.tar.xz kernel-qcow2-util-linux-d5878cabe6e9df5a9dacbbd637f53784d0b19928.zip |
lib/path: fix read string to be backwardly compatible
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/path.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/path.c b/lib/path.c index 998dce5bb..c665196a9 100644 --- a/lib/path.c +++ b/lib/path.c @@ -505,6 +505,10 @@ int ul_path_read_string(struct path_cxt *pc, char **str, const char *path) if (rc < 0 || !str) return rc;; + /* Remove tailing newline (usuall in sysfs) */ + if (rc > 0 && *(buf + rc - 1) == '\n') + --rc; + buf[rc] = '\0'; *str = strdup(buf); if (!*str) |