From b7213fc6c639b5ca6c91e215aee18cea36d9dc95 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Tue, 18 Feb 2025 14:29:50 -0600 Subject: [PATCH] sniffer: Add better coverage of skip_insignificant_space() --- libsoup/soup-content-sniffer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libsoup/soup-content-sniffer.c b/libsoup/soup-content-sniffer.c index 698d05e4..3fb29adf 100644 --- a/libsoup/soup-content-sniffer.c +++ b/libsoup/soup-content-sniffer.c @@ -612,8 +612,11 @@ sniff_text_or_binary (SoupContentSniffer *sniffer, SoupBuffer *buffer) } static gboolean -skip_insignificant_space (const char *resource, int *pos, int resource_length) +skip_insignificant_space (const char *resource, gsize *pos, gsize resource_length) { + if (*pos >= resource_length) + return TRUE; + while ((resource[*pos] == '\x09') || (resource[*pos] == '\x20') || (resource[*pos] == '\x0A') || @@ -632,7 +635,7 @@ sniff_feed_or_html (SoupContentSniffer *sniffer, SoupBuffer *buffer) { const char *resource = (const char *)buffer->data; int resource_length = MIN (512, buffer->length); - int pos = 0; + gsize pos = 0; if (resource_length < 3) goto text_html; @@ -642,9 +645,6 @@ sniff_feed_or_html (SoupContentSniffer *sniffer, SoupBuffer *buffer) pos = 3; look_for_tag: - if (pos > resource_length) - goto text_html; - if (skip_insignificant_space (resource, &pos, resource_length)) goto text_html; -- 2.49.0