add bounds to numbered input

This commit is contained in:
Quinn
2025-04-06 17:27:55 +02:00
parent 40aa1b59e6
commit 6ef3d4a660

View File

@@ -1,4 +1,5 @@
#include <errno.h>
#include <limits.h>
#include <linux/time.h>
#include <stdarg.h>
#include <stdint.h>
@@ -39,6 +40,7 @@ int main(int argc, char** argv) {
errno = 0;
long const c = strtol(argv[i], NULL, 10);
if (errno == EINVAL) error("syntax error for string: %s\n", argv[i]);
if (c < 1 || c > (LONG_MAX - 1)) error("count may only be in between 1 and %l. Received %l", LONG_MAX, c);
// perform for the input count
for (long j = 0; j < c; ++j) {