|
|
|
@ -338,12 +338,14 @@ static int stun_handle_packet(int s, struct sockaddr_in *src, unsigned char *dat
|
|
|
|
|
int resplen, respleft;
|
|
|
|
|
|
|
|
|
|
if (len < sizeof(struct stun_header)) {
|
|
|
|
|
if (option_debug)
|
|
|
|
|
ast_log(LOG_DEBUG, "Runt STUN packet (only %d, wanting at least %d)\n", len, sizeof(struct stun_header));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (stundebug)
|
|
|
|
|
ast_verbose("STUN Packet, msg %s (%04x), length: %d\n", stun_msg2str(ntohs(hdr->msgtype)), ntohs(hdr->msgtype), ntohs(hdr->msglen));
|
|
|
|
|
if (ntohs(hdr->msglen) > len - sizeof(struct stun_header)) {
|
|
|
|
|
if (option_debug)
|
|
|
|
|
ast_log(LOG_DEBUG, "Scrambled STUN packet length (got %d, expecting %d)\n", ntohs(hdr->msglen), len - sizeof(struct stun_header));
|
|
|
|
|
} else
|
|
|
|
|
len = ntohs(hdr->msglen);
|
|
|
|
@ -351,15 +353,18 @@ static int stun_handle_packet(int s, struct sockaddr_in *src, unsigned char *dat
|
|
|
|
|
memset(&st, 0, sizeof(st));
|
|
|
|
|
while(len) {
|
|
|
|
|
if (len < sizeof(struct stun_attr)) {
|
|
|
|
|
if (option_debug)
|
|
|
|
|
ast_log(LOG_DEBUG, "Runt Attribute (got %d, expecting %d)\n", len, sizeof(struct stun_attr));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
attr = (struct stun_attr *)data;
|
|
|
|
|
if (ntohs(attr->len) > len) {
|
|
|
|
|
if (option_debug)
|
|
|
|
|
ast_log(LOG_DEBUG, "Inconsistant Attribute (length %d exceeds remaining msg len %d)\n", ntohs(attr->len), len);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (stun_process_attr(&st, attr)) {
|
|
|
|
|
if (option_debug)
|
|
|
|
|
ast_log(LOG_DEBUG, "Failed to handle attribute %s (%04x)\n", stun_attr2str(ntohs(attr->attr)), ntohs(attr->attr));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|