[master] fa93cd8c7 vcc: Provision against exponent notation
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Aug 28 07:22:09 UTC 2023
commit fa93cd8c76e4a0bc8ea9259eb4cf892a1cfc145a
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Mon Aug 28 09:19:00 2023 +0200
vcc: Provision against exponent notation
It is no longer supported in VCL, but strtod() will accept it.
Fixes #3971
diff --git a/bin/varnishtest/tests/i00001.vtc b/bin/varnishtest/tests/i00001.vtc
index 08cb59add..c29ae5b34 100644
--- a/bin/varnishtest/tests/i00001.vtc
+++ b/bin/varnishtest/tests/i00001.vtc
@@ -16,6 +16,10 @@ varnish v1 -errvcl {Too many digits for real.} {
sub vcl_recv { set req.http.foo = 0.1234; }
}
+varnish v1 -errvcl {Unexpected character 'e'.} {
+ sub vcl_recv { set req.http.foo = 42.42e42; }
+}
+
server s1 {
rxreq
txresp
diff --git a/lib/libvcc/vcc_token.c b/lib/libvcc/vcc_token.c
index 79af6eb58..268d5d4a7 100644
--- a/lib/libvcc/vcc_token.c
+++ b/lib/libvcc/vcc_token.c
@@ -503,6 +503,12 @@ vcc_lex_number(struct vcc *tl, struct source *sp, const char *p)
vcc_ErrWhere(tl, tl->t);
return (NULL);
}
+ if (*tl->t->e == 'e' || *tl->t->e == 'E') {
+ VSB_printf(tl->sb, "Unexpected character '%c'.\n", *tl->t->e);
+ tl->t->e++;
+ vcc_ErrWhere(tl, tl->t);
+ return (NULL);
+ }
tl->t->num = strtod(p, &s);
assert(s == tl->t->e);
return (r);
More information about the varnish-commit
mailing list