summaryrefslogtreecommitdiffstats
path: root/login-utils/sulogin-consoles.c
diff options
context:
space:
mode:
authorGuillem Jover2015-06-06 06:26:43 +0200
committerKarel Zak2015-06-08 12:10:05 +0200
commit1c8beb3dfbb155b2cea3764a15d40fdd9038cf9f (patch)
treeea63d05e27c11721fa62b1e3ab22133a7bc49b5c /login-utils/sulogin-consoles.c
parentinclude/c: Define F_DUPFD_CLOEXEC on kFreeBSD systems if missing (diff)
downloadkernel-qcow2-util-linux-1c8beb3dfbb155b2cea3764a15d40fdd9038cf9f.tar.gz
kernel-qcow2-util-linux-1c8beb3dfbb155b2cea3764a15d40fdd9038cf9f.tar.xz
kernel-qcow2-util-linux-1c8beb3dfbb155b2cea3764a15d40fdd9038cf9f.zip
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 <guillem@hadrons.org>
Diffstat (limited to 'login-utils/sulogin-consoles.c')
-rw-r--r--login-utils/sulogin-consoles.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c
index 9fd103405..39d24d293 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)