Skip to content

Commit 9f7c64b

Browse files
committed
[Core] switch_stun.c: Coverity 1468480: Out-of-bounds access (OVERRUN)
1 parent 05e58fa commit 9f7c64b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/include/switch_stun.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ typedef struct {
141141
uint32_t address;
142142
} switch_stun_ip_t;
143143

144+
typedef struct {
145+
uint8_t wasted;
146+
uint8_t family;
147+
uint16_t port;
148+
uint8_t address[16];
149+
} switch_stun_ipv6_t;
150+
144151
#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
145152

146153
typedef struct {

src/switch_stun.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,17 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_s
401401
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_xor_mapped_address(switch_stun_packet_attribute_t *attribute, switch_stun_packet_header_t *header, char *ipstr, switch_size_t iplen, uint16_t *port)
402402
{
403403
switch_stun_ip_t *ip;
404+
switch_stun_ipv6_t *ipv6;
404405
uint8_t x, *i;
405406
char *p = ipstr;
406407

407408
ip = (switch_stun_ip_t *) attribute->value;
408409

409410
if (ip->family == 2) {
410-
uint8_t *v6addr = (uint8_t *) &ip->address;
411+
uint8_t *v6addr;
412+
413+
ipv6 = (switch_stun_ipv6_t *)attribute->value;
414+
v6addr = (uint8_t *) &ipv6->address;
411415
v6_xor(v6addr, (uint8_t *)header->id);
412416
inet_ntop(AF_INET6, v6addr, ipstr, iplen);
413417
} else {

0 commit comments

Comments
 (0)