[6.0] 1845b8937 vsl -R: Add strtol underflow/overflow handling
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Fri Feb 8 12:31:13 UTC 2019
commit 1845b8937c45df862bc36138a86b977f058392f8
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date: Mon Dec 3 14:31:35 2018 +0100
vsl -R: Add strtol underflow/overflow handling
Conflicts:
lib/libvarnishapi/vsl_arg.c
For some reason it was missing errno.h...
diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c
index 2929b4ccf..25402e583 100644
--- a/lib/libvarnishapi/vsl_arg.c
+++ b/lib/libvarnishapi/vsl_arg.c
@@ -31,6 +31,7 @@
#include "config.h"
#include <ctype.h>
+#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
@@ -310,7 +311,10 @@ vsl_R_arg(struct VSL_data *vsl, const char *arg)
AN(arg);
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
+ errno = 0;
l = strtol(arg, &p, 0);
+ if ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE)
+ return (vsl_diag(vsl, "-R: Range error"));
if (l <= 0 || l > INT_MAX)
return (vsl_diag(vsl, "-R: Range error"));
vsl->R_opt_l = l;
More information about the varnish-commit
mailing list