[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MiNT] [PATCH] getlogin() returns names truncated to 3 characters
Hello.
I noticed a a 13 years old bug.
The MiNTLib's getlogin() function currently returns names truncated to 3
characters. It is obviously a bug due to a misuse of sizeof() using pointer
instead of array.
Alan, please commit!
getlogin.patch
Fixed bug: getlogin() returned names truncated to 3 characters. Contributed
by Vincent Riviere.
--
Vincent Rivière
diff -aurN -x CVS mintlib.orig/mintlib/getlogin.c mintlib/mintlib/getlogin.c
--- mintlib.orig/mintlib/getlogin.c 2001-05-25 16:51:45.000000000 +0200
+++ mintlib/mintlib/getlogin.c 2014-11-03 21:05:57.406250000 +0100
@@ -25,14 +25,14 @@
temp = getpwuid (getuid ());
if (temp) {
- strncpy (tmplogname, temp->pw_name, sizeof (logname) - 1);
- tmplogname[sizeof (logname) - 1] = '\0';
+ strncpy (tmplogname, temp->pw_name, sizeof (tmplogname) - 1);
+ tmplogname[sizeof (tmplogname) - 1] = '\0';
}
/* if that didn't work, try the environment */
if (!*tmplogname && getenv ("USER")) {
- strncpy (tmplogname, getenv ("USER"), sizeof (logname) - 1);
- tmplogname[sizeof (logname) - 1] = '\0';
+ strncpy (tmplogname, getenv ("USER"), sizeof (tmplogname) - 1);
+ tmplogname[sizeof (tmplogname) - 1] = '\0';
}
/* finally, give up */