[master] e26533571 stevedore: Restore null check for properties

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Jan 8 13:57:10 UTC 2024


commit e265335716815c56757ecc606c152721e05973df
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Jan 8 14:51:59 2024 +0100

    stevedore: Restore null check for properties
    
    There is a default value when the property is not implemented and has no
    callback.
    
    Fixes #4036

diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 7813c424f..34f3919fe 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -306,6 +306,8 @@ VRT_stevedore_##nm(VCL_STEVEDORE stv)			\
 {							\
 	if (stv == NULL)				\
 		return (0);				\
+	if (stv->var_##nm == NULL)			\
+		return (dval);				\
 	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);	\
 	return (stv->var_##nm(stv));			\
 }
diff --git a/bin/varnishtest/tests/r04036.vtc b/bin/varnishtest/tests/r04036.vtc
new file mode 100644
index 000000000..a689680b9
--- /dev/null
+++ b/bin/varnishtest/tests/r04036.vtc
@@ -0,0 +1,15 @@
+varnishtest "Undefined storage properties"
+
+varnish v1 -arg "-s malloc=malloc -s file=file,${tmpdir}/file,1M" -vcl {
+	backend be none;
+
+	sub vcl_recv {
+		set req.http.happy = storage.malloc.happy;
+		set req.http.space = storage.file.free_space;
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+} -run


More information about the varnish-commit mailing list