Skip to content

Commit

Permalink
Fixing stack smashing because of wrong edge condition in argument whi…
Browse files Browse the repository at this point in the history
…le loop.
  • Loading branch information
RemcodM committed Dec 5, 2017
1 parent 392b397 commit da14019
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arg_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int get_argc(char *s)
sp++;
if (*sp == '\0')
return count;
else
else
count++;
while (!isspace(*sp) && *sp != '\0')
sp++;
Expand All @@ -33,7 +33,7 @@ char **get_args(char *s, int index)
{
char **args, arg[BUFSIZE], *argp;
int i;
args = (char **) malloc (BUFSIZ);
args = (char **) malloc (BUFSIZE);

s += index;
_argc = get_argc(s);
Expand All @@ -48,7 +48,7 @@ char **get_args(char *s, int index)
_argc--;
goto top;
}
while (!isspace(*s) || *s == '\0')
while (!isspace(*s) && *s != '\0')
*argp++ = *s++;

*argp = '\0';
Expand Down

0 comments on commit da14019

Please sign in to comment.