Skip to content

Commit

Permalink
fix numtrunc in str2wire.c
Browse files Browse the repository at this point in the history
  • Loading branch information
headshog committed Jul 17, 2023
1 parent 7240ecb commit 78c284e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sldns/rrdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 78c284e

Please sign in to comment.