mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
[MAN] AnalyzeArgv(): Fix 2 overruns related to element (#703)
- Also use _countof(). - Also add braces. - Also enforce consistent "no spaces" style. Thanks to "devpao" for pointing to this function. ROSAPPS-344
This commit is contained in:
parent
65a5a989c5
commit
d69d401325
1 changed files with 11 additions and 4 deletions
|
@ -88,7 +88,7 @@ Usage()
|
|||
int
|
||||
AnalyzeArgv(char *argument)
|
||||
{
|
||||
int element=0;
|
||||
int element;
|
||||
char HelpFlag=0;
|
||||
char *keys[]={"--help","/h","/?","-h"};
|
||||
char *sections[]={".1",".2",".3",".4",".5",".6",".7",".8",".9"};
|
||||
|
@ -96,25 +96,32 @@ AnalyzeArgv(char *argument)
|
|||
|
||||
strcpy(filename,argument); //save argument value
|
||||
|
||||
for(element=0; element < 5;element++)
|
||||
for(element=0;element<_countof(keys);element++)
|
||||
{
|
||||
if(!strcmp(keys[element],argument))
|
||||
{
|
||||
Usage();
|
||||
HelpFlag=1;
|
||||
}
|
||||
}
|
||||
|
||||
element = 0;
|
||||
|
||||
if(!HelpFlag)
|
||||
{
|
||||
|
||||
if(OpenF(filename))
|
||||
while(OpenF(strcat(filename,sections[element])) && (element<9))
|
||||
{
|
||||
while(element<_countof(sections)&&OpenF(strcat(filename,sections[element])))
|
||||
{
|
||||
strcpy(filename,argument);
|
||||
element++;
|
||||
}
|
||||
|
||||
if(element>8) printf("No manual for %s\n",argument);
|
||||
if(element>=_countof(sections)) printf("No manual for %s\n",argument);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue