lib/path: fix read string to be backwardly compatible
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
bcf445fd68
commit
d5878cabe6
|
@ -505,6 +505,10 @@ int ul_path_read_string(struct path_cxt *pc, char **str, const char *path)
|
||||||
if (rc < 0 || !str)
|
if (rc < 0 || !str)
|
||||||
return rc;;
|
return rc;;
|
||||||
|
|
||||||
|
/* Remove tailing newline (usuall in sysfs) */
|
||||||
|
if (rc > 0 && *(buf + rc - 1) == '\n')
|
||||||
|
--rc;
|
||||||
|
|
||||||
buf[rc] = '\0';
|
buf[rc] = '\0';
|
||||||
*str = strdup(buf);
|
*str = strdup(buf);
|
||||||
if (!*str)
|
if (!*str)
|
||||||
|
|
Loading…
Reference in New Issue