From: headshog Date: Tue, 11 Jul 2023 15:44:31 +0000 (+0300) Subject: fix numtrunc in str2wire.c X-Git-Tag: release-1.18.0rc1~24^2~9^2~1^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=78c284e05d9cbb7575b1b55ab6fef48c8ffcfb30;p=thirdparty%2Funbound.git fix numtrunc in str2wire.c --- diff --git a/sldns/rrdef.c b/sldns/rrdef.c index 322eff096..130324a1f 100644 --- a/sldns/rrdef.c +++ b/sldns/rrdef.c @@ -702,7 +702,11 @@ sldns_get_rr_type_by_name(const char *name) /* TYPEXX representation */ if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) { - return atoi(name + 4); + unsigned int a = atoi(name + 4); + if (a > LDNS_RR_TYPE_LAST) { + return (enum sldns_enum_rr_type)0; + } + return a; } /* Normal types */ @@ -740,7 +744,11 @@ sldns_get_rr_class_by_name(const char *name) /* CLASSXX representation */ if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) { - return atoi(name + 5); + unsigned int a = atoi(name + 5); + if (a > LDNS_RR_TYPE_LAST) { + return (enum sldns_enum_rr_type)0; + } + return a; } /* Normal types */