comparison 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
comparison
equal deleted inserted replaced
263:0e56fd09921e 264:94b7962a0fbe
5 the groups we know of. One database record is cached in the global struct 5 the groups we know of. One database record is cached in the global struct
6 grp. Group information is transfered between the grp and the database by 6 grp. Group information is transfered between the grp and the database by
7 loadGrp() and saveGrp(). This is done transparently. Access to the groups 7 loadGrp() and saveGrp(). This is done transparently. Access to the groups
8 database is done by group name, by the functions defined in group.h. 8 database is done by group name, by the functions defined in group.h.
9 9
10 $Id: group.c 382 2002-06-05 22:03:44Z mirkol $ 10 $Id: group.c 396 2002-08-05 22:05:02Z bears $
11 */ 11 */
12 12
13 #if HAVE_CONFIG_H 13 #if HAVE_CONFIG_H
14 #include <config.h> 14 #include <config.h>
15 #endif 15 #endif
464 */ 464 */
465 Bool 465 Bool
466 Grp_isValidName( const char *name) 466 Grp_isValidName( const char *name)
467 { 467 {
468 size_t i; 468 size_t i;
469 469 int len;
470 for ( i = 0; 470
471 i < sizeof( forbiddenGroupNames ) /
472 sizeof( struct ForbiddenGroupName );
473 ++i )
474 {
475 /* Negate result of Wld_match to ensure it is 1 or 0. */
476 if ( forbiddenGroupNames[i].match !=
477 ( ! Wld_match( name, forbiddenGroupNames[i].pattern ) ) )
478 return FALSE;
479 }
480 /* Groups with lengthy names like 471 /* Groups with lengthy names like
481 alt.the.lame.troll.should.be.posting.again.in.just.a.few.more.weeks.from.what.he.said 472 alt.the.lame.troll.should.be.posting.again.in.just.a.few.more.weeks.from.what.he.said
482 or 473 or
483 microsoft.public.windows.inetexplorer.ie55.programming.components.codedownload 474 microsoft.public.windows.inetexplorer.ie55.programming.components.codedownload
484 are most likely bogus groups that have been mistakenly created. 475 are most likely bogus groups that have been mistakenly created.
485 */ 476 */
486 if ( strlen( name ) > MAX_GROUPNAME ) 477 len = strlen( name );
478 if ( len > MAX_GROUPNAME || len < 1 )
487 return FALSE; 479 return FALSE;
480
481 for ( i = 0;
482 i < sizeof( forbiddenGroupNames ) /
483 sizeof( struct ForbiddenGroupName );
484 ++i )
485 {
486 /* Negate result of Wld_match to ensure it is 1 or 0. */
487 if ( forbiddenGroupNames[i].match !=
488 ( ! Wld_match( name, forbiddenGroupNames[i].pattern ) ) )
489 return FALSE;
490 }
488 /* no match? then assume the group is valid. */ 491 /* no match? then assume the group is valid. */
489 return TRUE; 492 return TRUE;
490 } 493 }