[PATCH] enforce maxlenght in usernames

Tito farmatito at tiscali.it
Wed Jul 27 19:33:08 UTC 2011


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: username_maxlength.patch
Type: text/x-patch
Size: 566 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20110727/21a6d1b4/attachment.bin>


More information about the busybox mailing list