properly detect period as last character in filename

(cherry picked from commit c9dc59eb90)
This commit is contained in:
Mark Andrews 2019-02-18 12:40:11 +11:00 committed by Evan Hunt
parent ab44b9a3ab
commit 21d6e9a91e
2 changed files with 4 additions and 4 deletions

View file

@ -112,10 +112,10 @@ is_safe(const char *input) {
if (i == 0)
return (false);
/* '..', two dots together is not allowed. */
else if (input[i-1] == '.')
if (input[i-1] == '.')
return (false);
/* '.' is not allowed as last char */
if (i == len)
if (i == len - 1)
return (false);
/* only 1 dot in ok location, continue at next char */
continue;

View file

@ -105,10 +105,10 @@ is_safe(const char *input) {
if (i == 0)
return (false);
/* '..', two dots together is not allowed. */
else if (input[i-1] == '.')
if (input[i-1] == '.')
return (false);
/* '.' is not allowed as last char */
if (i == len)
if (i == len - 1)
return (false);
/* only 1 dot in ok location, continue at next char */
continue;