]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: fix /etc/os-release parsing
authorKarel Zak <kzak@redhat.com>
Thu, 5 Oct 2017 09:07:41 +0000 (11:07 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 5 Oct 2017 09:07:41 +0000 (11:07 +0200)
For example /etc/os-release:

VERSION="26 (Twenty Six)"
VERSION_ID=26

agetty for \S{VERSION} returns

_ID=26

because the parser does nor check for '=' after variable name.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1498462
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index 956e8af97e1849426ccb0134fe5461e1d461cbfa..ee66a39481e0edc5fe90af2e8b3b7b05474a1cf4 100644 (file)
@@ -1438,6 +1438,7 @@ static char *xgetdomainname(void)
 #endif
 }
 
+
 static char *read_os_release(struct options *op, const char *varname)
 {
        int fd = -1;
@@ -1490,6 +1491,11 @@ static char *read_os_release(struct options *op, const char *varname)
                        continue;
                }
                p += varsz;
+               p += strspn(p, " \t\n\r");
+
+               if (*p != '=')
+                       continue;
+
                p += strspn(p, " \t\n\r=\"");
                eol = p + strcspn(p, "\n\r");
                *eol = '\0';