allow '_' chars in usernames provided to libfko
authorMichael Rash <mbr@cipherdyne.org>
Fri, 9 Nov 2012 02:02:44 +0000 (21:02 -0500)
committerMichael Rash <mbr@cipherdyne.org>
Fri, 9 Nov 2012 02:02:44 +0000 (21:02 -0500)
lib/fko_user.c
test/test-fwknop.pl

index 04b271a..00deb84 100644 (file)
@@ -130,13 +130,14 @@ validate_username(const char *username)
     if(username == NULL || strnlen(username, MAX_SPA_USERNAME_SIZE) == 0)
         return(FKO_ERROR_INVALID_DATA);
 
-    /* Make sure it is just alpha-numeric chars and dashes
+    /* Make sure it is just alpha-numeric chars, dashes, and underscores
     */
     if(isalnum(username[0]) == 0)
         return(FKO_ERROR_INVALID_DATA);
 
     for (i=1; i < strnlen(username, MAX_SPA_USERNAME_SIZE); i++)
-        if((isalnum(username[i]) == 0) && username[i] != '-')
+        if((isalnum(username[i]) == 0)
+                && username[i] != '-' && username[i] != '_')
             return(FKO_ERROR_INVALID_DATA);
 
     return FKO_SUCCESS;
index fb4320e..68b266e 100755 (executable)
@@ -3270,6 +3270,7 @@ sub valid_usernames() {
         'root',
         'mbr',
         'test-test',
+        'test_test',
         'someuser',
         'someUser',
         'USER',
@@ -3289,6 +3290,7 @@ sub fuzzing_usernames() {
         '123.123',
         '123$123',
         '-user',
+        '_user',
         '-User',
         ',User',
         'part1 part2',