Skip to content

eBPF-based security platform

otel: bound the gzip input before sizing its output

Daniel Borkmann8bf63de6ed83
diff --git a/util/upatch_maps_otel.c b/util/upatch_maps_otel.c
index 145bca9c..bb382fab 100644
--- a/util/upatch_maps_otel.c
+++ b/util/upatch_maps_otel.c
@@ -1296,9 +1296,11 @@ static int gzip_data(const char *in, size_t in_len,
int zr;
/* zlib counts in uInt; a longer input would be cut short silently. */
- if (in_len > UINT_MAX / 2)
+ if (in_len > UINT_MAX)
return -EFBIG;
cap = size_add(compressBound(in_len), 32);
+ if (cap > UINT_MAX)
+ return -EFBIG;
buf = xmalloc(cap);
if (!buf)
return -ENOMEM;