[master] a6bfa312e cache_http1_line: Flexelint: Avoid unchecked downcast

Nils Goroll nils.goroll at uplex.de
Mon Nov 25 14:43:03 UTC 2024


commit a6bfa312e288a9764a020e67b8c54d50037eb2d7
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Nov 1 09:04:57 2024 +0100

    cache_http1_line: Flexelint: Avoid unchecked downcast
    
    Found with less Flexelint silencing

diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index 771490986..39ba2356f 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -83,6 +83,7 @@ V1L_Open(struct ws *ws, int *fd, struct vsl_log *vsl,
 	struct v1l *v1l;
 	unsigned u;
 	uintptr_t ws_snap;
+	size_t sz;
 
 	if (WS_Overflowed(ws))
 		return (NULL);
@@ -119,7 +120,9 @@ V1L_Open(struct ws *ws, int *fd, struct vsl_log *vsl,
 	v1l->vsl = vsl;
 	v1l->werr = SC_NULL;
 
-	WS_Release(ws, u * sizeof(struct iovec));
+	sz = u * sizeof(struct iovec);
+	assert(sz < UINT_MAX);
+	WS_Release(ws, (unsigned)sz);
 	return (v1l);
 }
 


More information about the varnish-commit mailing list