chiark / gitweb /
sysusers: don't allow user names longer than UT_NAMESIZE
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Jul 2014 17:20:58 +0000 (19:20 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Jul 2014 17:22:13 +0000 (19:22 +0200)
As pointed out by Miloslav Trmač it might be a good idea to make sure
that usernames stay with in the utmp-defined limits.

man/sysusers.d.xml
src/sysusers/sysusers.c

index 549b3f6351eae3c3bf8019cdd25500e7699f6d07..40f8715bc0bbea51606c6508a3ece26c2b1d89bc 100644 (file)
@@ -142,7 +142,7 @@ m authd input</programlisting>
                         <title>Name</title>
 
                         <para>The name field specifies the user or
-                        group name. It should be be shorter than 256
+                        group name. It should be be shorter than 31
                         characters and avoid any non-ASCII characters,
                         and not begin with a numeric character. It is
                         strongly recommended to pick user and group
index 1765f31a3af32385155e4a940971902c50ba6d70..40a669725e7fff75b6cd2675498a14a0039ee447 100644 (file)
@@ -24,6 +24,7 @@
 #include <grp.h>
 #include <shadow.h>
 #include <getopt.h>
+#include <utmp.h>
 
 #include "util.h"
 #include "hashmap.h"
@@ -1095,6 +1096,9 @@ static bool valid_user_group_name(const char *u) {
         if ((size_t) (i-u) > (size_t) sz)
                 return false;
 
+        if ((size_t) (i-u) > UT_NAMESIZE - 1)
+                return false;
+
         return true;
 }