[Pkg-shadow-commits] r2748 - in upstream/trunk: . lib libmisc src
Nicolas FRANÇOIS
nekral-guest at alioth.debian.org
Wed Apr 22 20:42:48 UTC 2009
Author: nekral-guest
Date: 2009-04-22 20:42:48 +0000 (Wed, 22 Apr 2009)
New Revision: 2748
Modified:
upstream/trunk/ChangeLog
upstream/trunk/lib/defines.h
upstream/trunk/libmisc/chkname.c
upstream/trunk/src/login.c
Log:
* lib/defines.h: Define USER_NAME_MAX_LENGTH, based on utmp and
default to 32.
* libmisc/chkname.c: Use USER_NAME_MAX_LENGTH.
* src/login.c: Use USER_NAME_MAX_LENGTH instead of the default 32.
username also needs to be bigger than USER_NAME_MAX_LENGTH because
it has to be nul-terminated.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2009-04-22 20:21:17 UTC (rev 2747)
+++ upstream/trunk/ChangeLog 2009-04-22 20:42:48 UTC (rev 2748)
@@ -1,5 +1,14 @@
2009-04-22 Nicolas François <nicolas.francois at centraliens.net>
+ * lib/defines.h: Define USER_NAME_MAX_LENGTH, based on utmp and
+ default to 32.
+ * libmisc/chkname.c: Use USER_NAME_MAX_LENGTH.
+ * src/login.c: Use USER_NAME_MAX_LENGTH instead of the default 32.
+ username also needs to be bigger than USER_NAME_MAX_LENGTH because
+ it has to be nul-terminated.
+
+2009-04-22 Nicolas François <nicolas.francois at centraliens.net>
+
* src/login.c: Use xmalloc() instead of malloc().
2009-04-22 Nicolas François <nicolas.francois at centraliens.net>
Modified: upstream/trunk/lib/defines.h
===================================================================
--- upstream/trunk/lib/defines.h 2009-04-22 20:21:17 UTC (rev 2747)
+++ upstream/trunk/lib/defines.h 2009-04-22 20:42:48 UTC (rev 2748)
@@ -356,4 +356,19 @@
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#endif
+/* Maximum length of usernames */
+#ifdef HAVE_UTMPX_H
+# define USER_NAME_MAX_LENGTH (sizeof (((struct utmpx *)NULL)->ut_user))
+#else
+# ifdef HAVE_STRUCT_UTMP_UT_USER
+# define USER_NAME_MAX_LENGTH (sizeof (((struct utmp *)NULL)->ut_user))
+# else
+# ifdef HAVE_STRUCT_UTMP_UT_NAME
+# define USER_NAME_MAX_LENGTH (sizeof (((struct utmp *)NULL)->ut_name))
+# else
+# define USER_NAME_MAX_LENGTH 32
+# endif
+# endif
+#endif
+
#endif /* _DEFINES_H_ */
Modified: upstream/trunk/libmisc/chkname.c
===================================================================
--- upstream/trunk/libmisc/chkname.c 2009-04-22 20:21:17 UTC (rev 2747)
+++ upstream/trunk/libmisc/chkname.c 2009-04-22 20:42:48 UTC (rev 2748)
@@ -77,17 +77,11 @@
bool is_valid_user_name (const char *name)
{
-#if HAVE_UTMPX_H
- struct utmpx ut;
-#else
- struct utmp ut;
-#endif
-
/*
* User names are limited by whatever utmp can
* handle.
*/
- if (strlen (name) > sizeof (ut.ut_user)) {
+ if (strlen (name) > USER_NAME_MAX_LENGTH) {
return false;
}
Modified: upstream/trunk/src/login.c
===================================================================
--- upstream/trunk/src/login.c 2009-04-22 20:21:17 UTC (rev 2747)
+++ upstream/trunk/src/login.c 2009-04-22 20:42:48 UTC (rev 2748)
@@ -610,8 +610,9 @@
}
#ifdef RLOGIN
if (rflg) {
- username = xmalloc (32 * sizeof (char));
- if (do_rlogin (hostname, username, 32, term, sizeof term)) {
+ username = xmalloc (USER_NAME_MAX_LENGTH + 1);
+ username[USER_NAME_MAX_LENGTH] = '\0';
+ if (do_rlogin (hostname, username, USER_NAME_MAX_LENGTH, term, sizeof term)) {
preauth_flag = true;
} else {
free (username);
@@ -920,8 +921,9 @@
exit (1);
}
preauth_flag = false;
- username = xmalloc (32);
- login_prompt (_("\n%s login: "), username, 32);
+ username = xmalloc (USER_NAME_MAX_LENGTH + 1);
+ username[USER_NAME_MAX_LENGTH] = '\0';
+ login_prompt (_("\n%s login: "), username, USER_NAME_MAX_LENGTH);
if ('\0' == username) {
/* Prompt for a new login */
More information about the Pkg-shadow-commits
mailing list