diff src/group.c @ 264:94b7962a0fbe noffle

[svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one. * src/server.c: Correctly implement LISTGROUP when the optional group name parameter is omitted.
author bears
date Mon, 05 Aug 2002 23:05:02 +0100
parents 93d5d8b098da
children 5eece4dfd945
line wrap: on
line diff
--- a/src/group.c	Thu Jul 04 21:51:03 2002 +0100
+++ b/src/group.c	Mon Aug 05 23:05:02 2002 +0100
@@ -7,7 +7,7 @@
   loadGrp() and saveGrp(). This is done transparently. Access to the groups
   database is done by group name, by the functions defined in group.h.        
 
-  $Id: group.c 382 2002-06-05 22:03:44Z mirkol $
+  $Id: group.c 396 2002-08-05 22:05:02Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -466,6 +466,17 @@
 Grp_isValidName( const char *name)
 {
     size_t i;
+    int len;
+
+    /* Groups with lengthy names like
+       alt.the.lame.troll.should.be.posting.again.in.just.a.few.more.weeks.from.what.he.said
+       or
+       microsoft.public.windows.inetexplorer.ie55.programming.components.codedownload
+       are most likely bogus groups that have been mistakenly created.
+    */
+    len = strlen( name );
+    if ( len > MAX_GROUPNAME || len < 1 )
+        return FALSE;
     
     for ( i = 0;
           i < sizeof( forbiddenGroupNames ) /
@@ -477,14 +488,6 @@
              ( ! Wld_match( name, forbiddenGroupNames[i].pattern ) ) )
             return FALSE;
     }
-    /* Groups with lengthy names like
-       alt.the.lame.troll.should.be.posting.again.in.just.a.few.more.weeks.from.what.he.said
-       or
-       microsoft.public.windows.inetexplorer.ie55.programming.components.codedownload
-       are most likely bogus groups that have been mistakenly created.
-    */
-    if ( strlen( name ) > MAX_GROUPNAME )
-        return FALSE;
     /* no match? then assume the group is valid. */
     return TRUE;
 }