Check for 0 repeat count and tests in free

free checks for -c 0 now too.
testsuite has new checks for the checks.
This commit is contained in:
Craig Small
2012-01-04 10:07:31 +11:00
parent 223c95c95d
commit 5219a9c453
2 changed files with 20 additions and 7 deletions

2
free.c
View File

@@ -259,7 +259,7 @@ int main(int argc, char **argv)
flags |= FREE_REPEATCOUNT;
args.repeat_counter = strtol_or_err(optarg,
_("failed to parse count argument"));
if (args.repeat_counter > ULONG_MAX/2)
if (args.repeat_counter < 1 || args.repeat_counter > ULONG_MAX/2)
error(EXIT_FAILURE, ERANGE,
_("failed to parse count argument: '%s'"), optarg);
break;