summaryrefslogtreecommitdiffstats
path: root/lib/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/path.c')
-rw-r--r--lib/path.c4
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)