From 6aec9d62ef0f7521a99a9e9aadc064a11812fcf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Sun, 31 May 2026 13:57:10 +0200 Subject: [PATCH] whois.c: fix buffer overflows in convert_6to4 and convert_teredo --- whois.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/whois.c b/whois.c index 60063d7..a1434a2 100644 --- a/whois.c +++ b/whois.c @@ -1419,6 +1419,9 @@ char *convert_6to4(const char *s) b = 0; } + if (a > 0xFFFF || b > 0xFFFF) + return strdup("0.0.0.0"); + new = malloc(sizeof("255.255.255.255")); sprintf(new, "%u.%u.%u.%u", a >> 8, a & 0xff, b >> 8, b & 0xff); @@ -1435,6 +1438,10 @@ char *convert_teredo(const char *s) a ^= 0xffff; b ^= 0xffff; + + if (a > 0xFFFF || b > 0xFFFF) + return strdup("0.0.0.0"); + new = malloc(sizeof("255.255.255.255")); sprintf(new, "%u.%u.%u.%u", a >> 8, a & 0xff, b >> 8, b & 0xff);