[master] 5fb624078 Test strtoul() result comprehensively.

Poul-Henning Kamp phk at FreeBSD.org
Tue Sep 4 08:52:13 UTC 2018


commit 5fb62407820256dadedcf4f7ff3b6771cce6e517
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Sep 4 08:49:16 2018 +0000

    Test strtoul() result comprehensively.

diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c
index 942e25b97..8f02e6022 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -342,6 +342,7 @@ main(int argc, char **argv)
 {
 	int o, once = 0;
 	pthread_t thr;
+	char *e = NULL;
 
 	vut = VUT_InitProg(argc, argv, &vopt_spec);
 	AN(vut);
@@ -360,8 +361,9 @@ main(int argc, char **argv)
 			usage(0);
 		case 'p':
 			errno = 0;
-			period = strtol(optarg, NULL, 0);
-			if (errno != 0)  {
+			e = NULL;
+			period = strtoul(optarg, &e, 0);
+			if (errno != 0 || e == NULL || *e != '\0') {
 				fprintf(stderr,
 				    "Syntax error, %s is not a number", optarg);
 				exit(1);


More information about the varnish-commit mailing list