[master] b36272950 Coverity polish: 1605326 Overflowed integer argument
Nils Goroll
nils.goroll at uplex.de
Thu Sep 12 09:29:05 UTC 2024
commit b36272950440f0bf98240b7da85a9cec36b81b92
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Sep 12 11:26:47 2024 +0200
Coverity polish: 1605326 Overflowed integer argument
Turn l into the return type of WS_Dump() to avoid truncation from 64 to 32 bits.
diff --git a/vmod/vmod_vtc.c b/vmod/vmod_vtc.c
index 6c38db3ae..2d97b3543 100644
--- a/vmod/vmod_vtc.c
+++ b/vmod/vmod_vtc.c
@@ -248,7 +248,8 @@ vmod_workspace_dump(VRT_CTX, VCL_ENUM which, VCL_ENUM where,
VCL_BYTES off, VCL_BYTES len)
{
struct ws *ws;
- VCL_BYTES l, maxlen = 1024;
+ unsigned l;
+ const unsigned maxlen = 1024;
unsigned char buf[maxlen];
const char *p, *err;
@@ -267,6 +268,7 @@ vmod_workspace_dump(VRT_CTX, VCL_ENUM which, VCL_ENUM where,
}
l = WS_Dump(ws, *where, off, buf, len);
+ assert(l <= maxlen);
if (l == 0) {
switch (errno) {
@@ -279,8 +281,7 @@ vmod_workspace_dump(VRT_CTX, VCL_ENUM which, VCL_ENUM where,
return (NULL);
}
- assert(l < maxlen);
- p = WS_Copy(ctx->ws, buf, l);
+ p = WS_Copy(ctx->ws, buf, (int)l);
if (p == NULL) {
VRT_fail(ctx, "workspace_dump: copy failed");
return (NULL);
More information about the varnish-commit
mailing list