mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-24 22:58:21 +00:00
STUN/netsock2: Fix some valgrind uninitialized memory findings.
* netsock2.c: Test the addr->len member first as it may be the only member initialized in the struct. * stun.c:ast_stun_handle_packet(): The combinded[] local array could get used uninitialized by ast_stun_request(). The uninitialized string gets copied to another location and could overflow the destination memory buffer. These valgrind findings were found for ASTERISK_27150 but are not necessarily a fix for the issue. Change-Id: I55f8687ba4ffc0f69578fd850af006a56cbc9a57
This commit is contained in:
@@ -475,8 +475,12 @@ uint32_t ast_sockaddr_ipv4(const struct ast_sockaddr *addr)
|
||||
|
||||
int ast_sockaddr_is_ipv4(const struct ast_sockaddr *addr)
|
||||
{
|
||||
return addr->ss.ss_family == AF_INET &&
|
||||
addr->len == sizeof(struct sockaddr_in);
|
||||
/*
|
||||
* Test addr->len first to be tolerant of an ast_sockaddr_setnull()
|
||||
* addr. In that case addr->len might be the only value initialized.
|
||||
*/
|
||||
return addr->len == sizeof(struct sockaddr_in)
|
||||
&& addr->ss.ss_family == AF_INET;
|
||||
}
|
||||
|
||||
int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr)
|
||||
@@ -498,8 +502,12 @@ int ast_sockaddr_is_ipv6_link_local(const struct ast_sockaddr *addr)
|
||||
|
||||
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
|
||||
{
|
||||
return addr->ss.ss_family == AF_INET6 &&
|
||||
addr->len == sizeof(struct sockaddr_in6);
|
||||
/*
|
||||
* Test addr->len first to be tolerant of an ast_sockaddr_setnull()
|
||||
* addr. In that case addr->len might be the only value initialized.
|
||||
*/
|
||||
return addr->len == sizeof(struct sockaddr_in6)
|
||||
&& addr->ss.ss_family == AF_INET6;
|
||||
}
|
||||
|
||||
int ast_sockaddr_is_any(const struct ast_sockaddr *addr)
|
||||
|
Reference in New Issue
Block a user