From 3fa6fbe68b8b65bc7427b3686ba47c16767269f5 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sat, 15 Jun 2002 19:23:42 +0000 Subject: Prevent buffer overflow --- libc/unistd/getlogin.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libc/unistd/getlogin.c') diff --git a/libc/unistd/getlogin.c b/libc/unistd/getlogin.c index 505e6cf23..c762c366e 100644 --- a/libc/unistd/getlogin.c +++ b/libc/unistd/getlogin.c @@ -2,7 +2,7 @@ /* getlogin for uClibc * * Copyright (C) 2000 by Lineo, inc. and Erik Andersen - * Copyright (C) 2000,2001 by Erik Andersen + * Copyright (C) 2000-2002 by Erik Andersen * Written by Erik Andersen * * This program is free software; you can redistribute it and/or modify it @@ -23,11 +23,11 @@ #include #include -/* uClibc makes it policy to not mess with the utmp file whenever possible, * - * since I consider utmp a complete wasts of time. Since getlogin() should - * never be used for security purposes, we kindly let the user specify whatever - * they want via the LOGNAME environment variable, or we return NULL if - * getenv() fails to find anything */ +/* uClibc makes it policy to not mess with the utmp file whenever + * possible, since I consider utmp a complete waste of time. Since + * getlogin() should never be used for security purposes, we kindly let + * the user specify whatever they want via the LOGNAME environment + * variable, or we return NULL if getenv() fails to find anything */ char * getlogin(void) { @@ -42,6 +42,7 @@ int getlogin_r(char *name, size_t len) return -1; strncpy(name, foo, len); + name[len] = '\0'; return 0; } -- cgit v1.2.3