Skip to content

Commit

Permalink
[settings] Fix setting_cmp() to handle nameless settings
Browse files Browse the repository at this point in the history
setting_cmp() compares by option tag and then by name.  Empty names
will always match, which gives us a false positive.

Fix by explicitly checking for empty names.

Modified-by: Michael Brown <mcb30@etherboot.org>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
  • Loading branch information
Shao Miller authored and Michael Brown committed Jun 13, 2009
1 parent edfbd4e commit 68973f1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/settings.c
Expand Up @@ -782,8 +782,12 @@ int setting_cmp ( struct setting *a, struct setting *b ) {
if ( a->tag && ( a->tag == b->tag ) )
return 0;

/* Otherwise, compare the names */
return strcmp ( a->name, b->name );
/* Otherwise, if the settings have names, compare them */
if ( a->name && b->name && a->name[0] )
return strcmp ( a->name, b->name );

/* Otherwise, return a non-match */
return ( ! 0 );
}

/******************************************************************************
Expand Down

0 comments on commit 68973f1

Please sign in to comment.