Jelajahi Sumber

stun: catch udp ping 0000 when trying to parse stun headers

- avoid useless debug message
- info message made debug if the size of received packet is too small
for a stun header

(cherry picked from commit 7e08fc8d2b74657d6e6171effbab2770482d693e)
(cherry picked from commit 7d6dddfbf2ccadaf749496a4288f176b191350f2)
Daniel-Constantin Mierla 7 tahun lalu
induk
melakukan
a43fb8cafe
1 mengubah file dengan 5 tambahan dan 1 penghapusan
  1. 5 1
      src/modules/stun/kam_stun.c

+ 5 - 1
src/modules/stun/kam_stun.c

@@ -165,8 +165,12 @@ static int stun_parse_header(struct stun_msg* req, USHORT_T* error_code)
 {
 	
 	if (sizeof(req->hdr) > req->msg.buf.len) {
+		if(req->msg.buf.len==4 && *((int*)req->msg.buf.s)==0) {
+			/* likely the UDP ping 0000 */
+			return FATAL_ERROR;
+		}
 		/* the received message does not contain whole header */
-		LOG(L_INFO, "INFO: stun_parse_header: incomplete header of STUN message\n");
+		LM_DBG("incomplete header of STUN message\n");
 		/* Any better solution? IMHO it's not possible to send error response
 		 * because the transaction ID is not available.
 		 */