From 1c8beb3dfbb155b2cea3764a15d40fdd9038cf9f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 6 Jun 2015 06:26:43 +0200 Subject: [PATCH] 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 --- login-utils/sulogin-consoles.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) -- 2.47.2