From 149c82cad2cbdb5b2e740c4ad484e812a161fe8a Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Fri, 27 Mar 2026 15:43:49 +0200 Subject: [PATCH] block: Use glib2 instead of strcasecmp/strncasecmp This is a change in semantics. g_ascii_strcasecmp() doesn't honour locale but strcasecmp() does. But this is OK for at least one reason: (1) QEMU always runs with the C locale so there's not an actual behaviour change here (2) we want the comparison on url prefix and it should be a plain ASCII one, not to do weird things with "I" in Turkish locales, so g_ascii_strcasecmp() is better as it's explicit about that Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Peter Maydell Link: https://lore.kernel.org/r/20260327134401.270186-4-kkostiuk@redhat.com Signed-off-by: Paolo Bonzini --- block/curl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/curl.c b/block/curl.c index 419df78258..684c677ef7 100644 --- a/block/curl.c +++ b/block/curl.c @@ -871,8 +871,8 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, goto out; } - if ((!strncasecmp(s->url, "http://", strlen("http://")) - || !strncasecmp(s->url, "https://", strlen("https://"))) + if ((!g_ascii_strncasecmp(s->url, "http://", strlen("http://")) + || !g_ascii_strncasecmp(s->url, "https://", strlen("https://"))) && !s->accept_range) { pstrcpy(state->errmsg, CURL_ERROR_SIZE, "Server does not support 'range' (byte ranges).");