wapbox: wtls crash

Armindo Antunes <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,
I've found a bug on wap/wtls_pdu.c file, wtls_payload_dump function.
This function may be called with an NULL payload (when wtls_decrypt 
outputs the error: ERROR: wtls_decrypt: Rejected packet due to bad MAC) 
which causes a segmentation fault.

I've attached the patch with the fix for the current trunk version.

Best regards,
Armindo Antunes
wtls_pdu.c.patch (text/plain, 654 B)
Index: wap/wtls_pdu.c
===================================================================
--- wap/wtls_pdu.c	(revision 4951)
+++ wap/wtls_pdu.c	(working copy)
@@ -1121,12 +1121,12 @@
 
 void wtls_payload_dump(wtls_Payload * payload, int level)
 {
-   char *dbg = "wap.wtls", type[20], *data =
-       octstr_get_cstr(payload->data);
+   char *dbg = "wap.wtls", type[20], *data;
+   if (!payload)
+      return;
+   data = octstr_get_cstr(payload->data);
 
 	/* the message type */
-   if (!payload)
-      return;
    pduName(type, payload->type);
    debug(dbg, 0, "%*sPayload type: %s", level, "", type);
    if (payload->type == Handshake_PDU) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.