From 5c4e65fd99ff4e3ae76c7985c5e160bb07ea0f92 Mon Sep 17 00:00:00 2001 From: Changqing Li Date: Wed, 25 Mar 2026 11:24:36 +0800 Subject: [PATCH] sniffer: Handle potential underflow Closes #498 Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libsoup/-/commit/b91bbd7d7888c85b17a8b33173caa806dff51681] CVE: CVE-2026-2369 Signed-off-by: Changqing Li --- libsoup/soup-content-sniffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libsoup/soup-content-sniffer.c b/libsoup/soup-content-sniffer.c index 3edc568..b091bca 100644 --- a/libsoup/soup-content-sniffer.c +++ b/libsoup/soup-content-sniffer.c @@ -504,6 +504,10 @@ sniff_unknown (SoupContentSniffer *sniffer, SoupBuffer *buffer, if (!sniff_scriptable && type_row->scriptable) continue; + /* Ensure we have data to sniff - prevents underflow in resource_length - 1 */ + if (resource_length == 0) + continue; + if (type_row->has_ws) { guint index_stream = 0; guint index_pattern = 0; -- 2.34.1