[6.0] 14c846fcf Test strtoul() result comprehensively.

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Oct 31 13:08:13 UTC 2018


commit 14c846fcfef111c3ebc16827ac7a44700fefe2e3
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 0550f8abc..2247cca0f 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -343,6 +343,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);
@@ -361,8 +362,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