Skip to content

Commit

Permalink
fix numtrunc in str2wire.c and rrdef.c
Browse files Browse the repository at this point in the history
  • Loading branch information
headshog committed Jul 17, 2023
1 parent 221a792 commit 1ac12f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions sldns/rrdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,12 @@ sldns_get_rr_type_by_name(const char *name)

/* TYPEXX representation */
if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
unsigned int a = atoi(name + 4);
assert(a <= LDNS_RR_TYPE_LAST);
return a;
unsigned int a = atoi(name + 4);
if (a > LDNS_RR_TYPE_LAST) {
return (enum sldns_enum_rr_type)0;
}
return a;
}

/* Normal types */
for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) {
Expand Down
2 changes: 1 addition & 1 deletion smallapp/unbound-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ massage_type(const char* t, int reverse, int* multi)
if(t) {
int r = sldns_get_rr_type_by_name(t);
if(r == 0 && strcasecmp(t, "TYPE0") != 0 &&
strcmp(t, "") != 0) {
strcmp(t, "") != 0) {
fprintf(stderr, "error unknown type %s\n", t);
exit(1);
}
Expand Down

0 comments on commit 1ac12f7

Please sign in to comment.