Hi,
while reading man useradd on my box I stumbles across this line:

Usernames may only be up to 32 characters long.


So it seems to be a good idea to enforce this also in busybox.
I've added the relevant code to the die_if_bad_username libb function.
Please apply if you like it.  Hints, critics and improvements are welcome.
Ciao,
Tito


--- libbb/die_if_bad_username.c.orig    2011-02-03 21:30:50.000000000 +0100
+++ libbb/die_if_bad_username.c 2011-07-27 21:20:08.000000000 +0200
@@ -18,6 +18,9 @@
 
 void FAST_FUNC die_if_bad_username(const char *name)
 {
+       /* Usernames may only be up to 32 characters long. */
+       if (!name || !*name || strlen(name) > 32)
+               bb_error_msg_and_die("illegal name");
        /* 1st char being dash or dot isn't valid: */
        goto skip;
        /* For example, name like ".." can make adduser
Enforce 32 charcacters username max length.

Signed-off-by: Tito Ragusa <[email protected]>

--- libbb/die_if_bad_username.c.orig	2011-02-03 21:30:50.000000000 +0100
+++ libbb/die_if_bad_username.c	2011-07-27 21:20:08.000000000 +0200
@@ -18,6 +18,9 @@
 
 void FAST_FUNC die_if_bad_username(const char *name)
 {
+	/* Usernames may only be up to 32 characters long. */
+	if (!name || !*name || strlen(name) > 32)
+		bb_error_msg_and_die("illegal name");
 	/* 1st char being dash or dot isn't valid: */
 	goto skip;
 	/* For example, name like ".." can make adduser
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to