@samitouri / QOSamiQemu / commits / b25ab2e773

io: 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 data in HTTP header 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 <kkostiuk@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Link: https://lore.kernel.org/r/20260327134401.270186-5-kkostiuk@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Kostiantyn Kostiuk committed Mar 27, 2026 at 15:43 UTC b25ab2e77388001e60217128e404fe8f9fa051eb
1 file changed +2 -2
io/channel-websock.c
+2 -2
@@ -457,7 +457,7 @@ static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc,
457 connectionv = g_strsplit(connection, ",", 0);
458 for (i = 0; connectionv != NULL && connectionv[i] != NULL; i++) {
459 g_strstrip(connectionv[i]);
460 - if (strcasecmp(connectionv[i],
460 + if (g_ascii_strcasecmp(connectionv[i],
461 QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) == 0) {
462 upgraded = true;
463 }
@@ -468,7 +468,7 @@ static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc,
468 goto bad_request;
469 }
470
471 - if (strcasecmp(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET) != 0) {
471 + if (g_ascii_strcasecmp(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET) != 0) {
472 error_setg(errp, "Incorrect upgrade method '%s'", upgrade);
473 goto bad_request;
474 }