From 8c2030fd894ac1539a46a976fe0e551b143a6140 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 11 Oct 2020 11:48:43 +0200 Subject: [PATCH] Disallow limit <= 0. --- plocate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plocate.cpp b/plocate.cpp index 9f3928b..c914002 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -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; -- 2.39.2