Patch to remove: PANIC: wap/cookies.c:349: add_cookie_to_cache: Assertion `sm -> cookies != NUL
"Jakob Dalsgaard" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
To Kannel Development
I've been experiencing a panic from the wapbox saying:
2004-01-28 15:57:07 [1059] [7] DEBUG: Caching cookie (Set-Cookie:
WEBTRENDS_ID=212.99.225.2-12986640.29615535;Path=/)
2004-01-28 15:57:07 [1059] [7] DEBUG: get_header_value: Value
(WEBTRENDS_ID=212.99.225.2-12986640.29615535;Path=/)
2004-01-28 15:57:07 [1059] [7] ERROR: have_cookie: Null argument(s) - no
Cookie list, Cookie or both
2004-01-28 15:57:07 [1059] [7] PANIC: wap/cookies.c:349:
add_cookie_to_cache: Assertion `sm -> cookies != NULL' failed.
2004-01-28 15:57:07 [1059] [7] PANIC:
/home/SEM/opt/kannel-cvs/sbin/wapbox [0x80c33b0]
2004-01-28 15:57:07 [1059] [7] PANIC:
/home/SEM/opt/kannel-cvs/sbin/wapbox [0x80776ea]
2004-01-28 15:57:07 [1059] [7] PANIC:
/home/SEM/opt/kannel-cvs/sbin/wapbox [0x8076e92]
2004-01-28 15:57:07 [1059] [7] PANIC:
/home/SEM/opt/kannel-cvs/sbin/wapbox [0x8051f0a]
2004-01-28 15:57:07 [1059] [7] PANIC:
/home/SEM/opt/kannel-cvs/sbin/wapbox [0x8052b26]
2004-01-28 15:57:07 [1059] [7] PANIC:
/home/SEM/opt/kannel-cvs/sbin/wapbox [0x80b8a55]
2004-01-28 15:57:07 [1059] [7] PANIC: /lib/i686/libpthread.so.0 [0x400a6faf]
2004-01-28 15:57:07 [1059] [7] PANIC:
/home/SEM/opt/kannel-cvs/sbin/wapbox(__clone+0x3a) [0x420e790a]
And since I'm about to find out where to put my header rewriting stuff,
I thought I'd take a look at why I got this error first.
It seems that, when connecting to my Tomcat Webapp, the wapbox tries to
check if there is a cookie, before the WSPMachine->cookies list has been
created, resulting in a fatal error when the cookie is being added. The
section of code in wap-appl.c that starts all this is:
#ifdef ENABLE_COOKIES
if (session_id != -1)
/* DAVI if (get_cookies(url, headers,
find_session_machine_by_id(session_id)) == -1) */
if (get_cookies(headers,
find_session_machine_by_id(session_id)) == -1)
error(0, "WSP: Failed to extract cookies");
#endif
So it would seem that if the session is created (session_id != -1) then
the application assumes that the session machine has a properly
initialized cookies list. This is however not always the case. Perhaps
the proper place to correct this would be in the create_machine function
-- but a quick fix is to check if the state machine has a cookies !=
NULL -- whether this is correct, I do not know. Furthermore the "sm"
variable has previously been initialized to contain
find_session_machine_by_id(session_id); and session_id has not been
changed at this point; my version is thus:
#ifdef ENABLE_COOKIES
if (session_id != -1)
/* DAVI if (get_cookies(url, headers,
find_session_machine_by_id(session_id)) == -1) */
/* Verify that WSPMachine was found and has a cookies list */
if (sm != NULL && sm -> cookies != NULL &&
get_cookies(headers, sm) == -1)
error(0, "WSP: Failed to extract cookies");
#endif
A "cvs diff -u gw/wap-appl.c" is attached to this email.
If someone else is having these problems - this patch might help them...
/Jakob
--
Med venlig hilsen/Best regards
Jakob Dalsgaard
=================================
Cyber Com Group A/S
Mail: [email protected]
Web: http://www.cybercomgroup.com
GSM: +45 2948 3803
###########################################
This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.F-Secure.com/
sm-cookie-patch-jd-20040129.patch
(application/octet-stream, 776 B)
Index: gw/wap-appl.c
===================================================================
RCS file: /home/cvs/gateway/gw/wap-appl.c,v
retrieving revision 1.103
diff -u -r1.103 wap-appl.c
--- gw/wap-appl.c 22 Jan 2004 14:08:24 -0000 1.103
+++ gw/wap-appl.c 29 Jan 2004 11:12:03 -0000
@@ -823,7 +823,8 @@
#ifdef ENABLE_COOKIES
if (session_id != -1)
/* DAVI if (get_cookies(url, headers, find_session_machine_by_id(session_id)) == -1) */
- if (get_cookies(headers, find_session_machine_by_id(session_id)) == -1)
+ /* Verify that WSPMachine was found and has a cookies list */
+ if (sm != NULL && sm -> cookies != NULL && get_cookies(headers, sm) == -1)
error(0, "WSP: Failed to extract cookies");
#endif