tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

chat/pidgin segfault with NetBSD 11 (fixed)



Hi,

Just after upgrading to NetBSD-11 -current from a 10.99, chat/pidgin
started to segfault. This is actually due to isspace(3) called with a
signed char, upon reception of a non-ASCII char >0x7f in a chat
message.

Sigh, it took me like the entire day (night) to debug and come up to
this conclusion ... Anyway, patch attached :)

Shouldn't the warning -Wchar-subscripts be turned into an error, at
least in pkgsrc? It seems to me like something has changed in
NetBSD-11 and isspace(3), since pidgin has worked for me for a couple
of decades with this issue. But maybe that's just the UB effect that
suddenly decided to trigger...

Cheers,
Anthony

Fix -Wchar-subscripts

The code isspace(*(c - 1)) below actually later triggers a segfault in
NetBSD-11 when passed a non-ASCII char in the range [0x80-0xff].

--- pidgin/gtkimhtml.c~	2024-09-17 10:52:23.000000000 +0200
+++ pidgin/gtkimhtml.c	2025-10-05 04:44:34.643159904 +0200
@@ -3095,7 +3095,7 @@
 							} else if (*size == '-') {
 								sscanf (size + 1, "%hd", &font->size);
 								font->size = MAX (0, 3 - font->size);
-							} else if (isdigit (*size)) {
+							} else if (isdigit ((unsigned char)*size)) {
 								sscanf (size, "%hd", &font->size);
 							}
 							if (font->size > 100)
@@ -3512,9 +3512,9 @@
 			}
 			c++;
 			pos++;
-		} else if ((pos == 0 || wpos == 0 || isspace(*(c - 1))) &&
+		} else if ((pos == 0 || wpos == 0 || isspace((unsigned char)*(c - 1))) &&
 		           (len_protocol = gtk_imhtml_is_protocol(c)) > 0 &&
-				   c[len_protocol] && !isspace(c[len_protocol]) &&
+				   c[len_protocol] && !isspace((unsigned char)c[len_protocol]) &&
 				   (c[len_protocol] != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) {
 			br = FALSE;
 			if (wpos > 0) {


Home | Main Index | Thread Index | Old Index