Skip to content

Commit

Permalink
EnableDisableExtensionError: Use ARRAY_SIZE rather than sentinel
Browse files Browse the repository at this point in the history
d785368 converted the other miinitext functions to use ARRAY_SIZE,
and removed the sentinel, but missed EnableDisableExtensionError so
passing an invalid extension name could cause the server to walk off
the end off the list looking for a sentinel that wasn't there.

Signed-off-by: Alan Coopersmith <[email protected]>
Reviewed-by: Peter Hutterer <[email protected]>
  • Loading branch information
alanc committed Dec 18, 2012
1 parent 07a91fa commit 9ff2e83
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mi/miinitext.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,12 @@ EnableDisableExtension(const char *name, Bool enable)
void
EnableDisableExtensionError(const char *name, Bool enable)
{
ExtensionToggle *ext = &ExtensionToggleList[0];
ExtensionToggle *ext;
int i;
Bool found = FALSE;

for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) {
for (i = 0; i < ARRAY_SIZE(ExtensionToggleList); i++) {
ext = &ExtensionToggleList[i];
if ((strcmp(name, ext->name) == 0) && (ext->disablePtr == NULL)) {
ErrorF("[mi] Extension \"%s\" can not be disabled\n", name);
found = TRUE;
Expand All @@ -226,7 +228,8 @@ EnableDisableExtensionError(const char *name, Bool enable)
ErrorF("[mi] Extension \"%s\" is not recognized\n", name);
ErrorF("[mi] Only the following extensions can be run-time %s:\n",
enable ? "enabled" : "disabled");
for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) {
for (i = 0; i < ARRAY_SIZE(ExtensionToggleList); i++) {
ext = &ExtensionToggleList[i];
if (ext->disablePtr != NULL) {
ErrorF("[mi] %s\n", ext->name);
}
Expand Down

0 comments on commit 9ff2e83

Please sign in to comment.