mirror of
https://github.com/NLnetLabs/unbound.git
synced 2024-09-21 06:37:08 +00:00
- Fix for WKS call to getservbyname that creates allocation on exit
in unit test by testing numbers first and testing from the services list later.
This commit is contained in:
parent
ba1183bb6e
commit
d4c4537b33
@ -1,3 +1,8 @@
|
||||
30 August 2023: Wouter
|
||||
- Fix for WKS call to getservbyname that creates allocation on exit
|
||||
in unit test by testing numbers first and testing from the services
|
||||
list later.
|
||||
|
||||
28 August 2023: Wouter
|
||||
- Fix for version generation race condition that ignored changes.
|
||||
|
||||
|
@ -2459,12 +2459,13 @@ int sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len)
|
||||
(void)strlcpy(proto_str, token, sizeof(proto_str));
|
||||
} else {
|
||||
int serv_port;
|
||||
struct servent *serv = getservbyname(token, proto_str);
|
||||
if(serv) serv_port=(int)ntohs((uint16_t)serv->s_port);
|
||||
if(atoi(token) != 0) serv_port=atoi(token);
|
||||
else if(strcmp(token, "0") == 0) serv_port=0;
|
||||
else if(strcasecmp(token, "domain")==0) serv_port=53;
|
||||
else {
|
||||
serv_port = atoi(token);
|
||||
if(serv_port == 0 && strcmp(token, "0") != 0) {
|
||||
struct servent *serv = getservbyname(token, proto_str);
|
||||
if(serv) serv_port=(int)ntohs((uint16_t)serv->s_port);
|
||||
else {
|
||||
#ifdef HAVE_ENDSERVENT
|
||||
endservent();
|
||||
#endif
|
||||
@ -2474,16 +2475,16 @@ int sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len)
|
||||
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX,
|
||||
sldns_buffer_position(&strbuf));
|
||||
}
|
||||
if(serv_port < 0 || serv_port > 65535) {
|
||||
}
|
||||
if(serv_port < 0 || serv_port > 65535) {
|
||||
#ifdef HAVE_ENDSERVENT
|
||||
endservent();
|
||||
endservent();
|
||||
#endif
|
||||
#ifdef HAVE_ENDPROTOENT
|
||||
endprotoent();
|
||||
endprotoent();
|
||||
#endif
|
||||
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX,
|
||||
sldns_buffer_position(&strbuf));
|
||||
}
|
||||
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX,
|
||||
sldns_buffer_position(&strbuf));
|
||||
}
|
||||
if(rd_len < 1+serv_port/8+1) {
|
||||
/* bitmap is larger, init new bytes at 0 */
|
||||
|
Loading…
Reference in New Issue
Block a user