]> git.sesse.net Git - plocate/commitdiff
Disallow limit <= 0.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Sun, 11 Oct 2020 09:48:43 +0000 (11:48 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Sun, 11 Oct 2020 09:48:43 +0000 (11:48 +0200)
plocate.cpp

index 9f3928b1a8349e8db0e57d82bb31fd8df59171ef..c914002ff87b3bcbd61b0ad02d9d0cd81da03554 100644 (file)
@@ -668,6 +668,10 @@ int main(int argc, char **argv)
                case 'l':
                case 'n':
                        limit_matches = atoll(optarg);
+                       if (limit_matches <= 0) {
+                               fprintf(stderr, "Error: limit must be a strictly positive number.\n");
+                               exit(1);
+                       }
                        break;
                case '0':
                        print_nul = true;