Set default port of 0 when parsing addresses

Default port should be zero when address parsing so other parts of the
library can set the emphereal source port.
Origin: 06a02b7c70
Bug: https://sourceforge.net/p/net-snmp/bugs/2978/
Reviewed-by: Craig Small <csmall@debian.org>
Last-Update: 2019-09-30

Gbp-Pq: Name parsing_default_port
This commit is contained in:
Ubuntu Developers 2022-06-27 15:01:26 +08:00 committed by Lu zhiping
parent 56d07bb97a
commit 2cccd4038c
2 changed files with 3 additions and 3 deletions

View File

@ -317,7 +317,7 @@ netsnmp_udpipv4base_tspec_transport(netsnmp_tdomain_spec *tspec)
if (NULL != tspec->source) {
struct sockaddr_in src_addr, *srcp = &src_addr;
/** get sockaddr from source */
if (!netsnmp_sockaddr_in2(&src_addr, tspec->source, NULL))
if (!netsnmp_sockaddr_in2(&src_addr, tspec->source, ":0"))
return NULL;
return netsnmp_udpipv4base_transport_with_source(&addr, local, srcp);
} else {

View File

@ -383,7 +383,7 @@ netsnmp_udpipv6base_tspec_transport(netsnmp_tdomain_spec *tspec)
if (NULL != tspec->source) {
struct sockaddr_in6 src_addr, *srcp = &src_addr;
/** get sockaddr from source */
if (!netsnmp_sockaddr_in6_2(&src_addr, tspec->source, NULL))
if (!netsnmp_sockaddr_in6_2(&src_addr, tspec->source, ":0"))
return NULL;
return netsnmp_udp6_transport_with_source(&addr, local, srcp);
} else {
@ -464,7 +464,7 @@ netsnmp_udp6_transport(const struct sockaddr_in6 *addr, int local)
NETSNMP_DS_LIB_CLIENT_ADDR);
if (client_socket) {
struct sockaddr_in6 client_addr;
if(!netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL)) {
if(!netsnmp_sockaddr_in6_2(&client_addr, client_socket, ":0")) {
return netsnmp_udp6_transport_with_source(addr, local,
&client_addr);
}