From: Guillem Jover Date: Sat, 6 Jun 2015 04:26:43 +0000 (+0200) Subject: sulogin: Use read instead of allocated size from getline() X-Git-Tag: v2.27-rc1~161 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c8beb3dfbb155b2cea3764a15d40fdd9038cf9f;p=thirdparty%2Futil-linux.git sulogin: Use read instead of allocated size from getline() The getline function distinguishes between the allocated and read lenghts, and we should not mix them up, as we might end up processing junk. Signed-off-by: Guillem Jover --- diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c index 9fd1034056..39d24d293f 100644 --- a/login-utils/sulogin-consoles.c +++ b/login-utils/sulogin-consoles.c @@ -154,13 +154,15 @@ char *oneline(const char *file) { FILE *fp; char *ret = NULL; - size_t len = 0; + size_t dummy = 0; + ssize_t len; DBG(dbgprint("reading %s", file)); if (!(fp = fopen(file, "re"))) return NULL; - if (getline(&ret, &len, fp) >= 0) { + len = getline(&ret, &dummy, fp); + if (len >= 0) { char *nl; if (len)