diff options
author | Frank Binns <[email protected]> | 2016-08-04 15:15:23 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2016-09-01 15:48:34 +0100 |
commit | d5f65b8bf54574e45d73938702fb5505449c1b5d (patch) | |
tree | f832cb4505cd5c957cefdf30d9c2dcec8e1130b0 /src/loader | |
parent | d6f669ba834697b7321c7ea2cbb38794385c7205 (diff) |
loader: fix sysfs uevent file parsing
When trying to get a device name for an fd using sysfs, it would always fail
as it was expecting key/value pairs to be delimited by '\0', which is not the
case.
Signed-off-by: Frank Binns <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/loader')
-rw-r--r-- | src/loader/loader.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/loader/loader.c b/src/loader/loader.c index 56ffc5d77a7..3e60e4ccf1d 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -645,7 +645,7 @@ sysfs_get_device_name_for_fd(int fd) unsigned int maj, min; FILE *f; char buf[0x40]; - static const char match[9] = "\0DEVNAME="; + static const char match[9] = "\nDEVNAME="; int expected = 1; if (dev_node_from_fd(fd, &maj, &min) < 0) @@ -668,8 +668,10 @@ sysfs_get_device_name_for_fd(int fd) } strcpy(buf, "/dev/"); - if (fgets(buf + 5, sizeof(buf) - 5, f)) + if (fgets(buf + 5, sizeof(buf) - 5, f)) { + buf[strcspn(buf, "\n")] = '\0'; device_name = strdup(buf); + } fclose(f); return device_name; |