diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-12-18 00:41:08 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-12-18 15:35:02 -0800 |
commit | 9ff2e831517875f96477862f979abff394e8d551 (patch) | |
tree | 9c597993cfb3fe98159edd9706d3563ef2c48ca1 /mi | |
parent | 07a91fa6c6d535f3f05d4c3bd9c4d2b8c382c475 (diff) |
EnableDisableExtensionError: Use ARRAY_SIZE rather than sentinel
d785368e0e 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 <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'mi')
-rw-r--r-- | mi/miinitext.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mi/miinitext.c b/mi/miinitext.c index 369da5ede..81c663abe 100644 --- a/mi/miinitext.c +++ b/mi/miinitext.c @@ -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; @@ -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); } |