qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block/curl: explicitly assert that strchr returns non-NULL value
@ 2024-06-27 15:30 Vladimir Sementsov-Ogievskiy
  2024-06-27 18:05 ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-06-27 15:30 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, vsementsov, hreitz, kwolf, qemu-trivial

strchr may return NULL if colon is not found. It seems clearer to
assert explicitly that we don't expect it here, than dereference 1 in
the next line.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 block/curl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/curl.c b/block/curl.c
index 419f7c89ef..ccfffd6c12 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -219,7 +219,9 @@ static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
         && g_ascii_strncasecmp(header, accept_ranges,
                                strlen(accept_ranges)) == 0) {
 
-        char *p = strchr(header, ':') + 1;
+        char *p = strchr(header, ':');
+        assert(p != NULL);
+        p += 1;
 
         /* Skip whitespace between the header name and value. */
         while (p < end && *p && g_ascii_isspace(*p)) {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-28  5:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-27 15:30 [PATCH] block/curl: explicitly assert that strchr returns non-NULL value Vladimir Sementsov-Ogievskiy
2024-06-27 18:05 ` Kevin Wolf
2024-06-28  5:34   ` Vladimir Sementsov-Ogievskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).