
date: 2002/06/04 17:32:14;  author: temas;  state: Exp;  lines: +11 -2
Fix for bad route packets

Index: jsm/deliver.c
===================================================================
RCS file: /home/cvs/jabberd14/jsm/deliver.c,v
retrieving revision 1.33
retrieving revision 1.35
diff -u -r1.33 -r1.35
--- jsm/deliver.c	8 Feb 2002 07:44:16 -0000	1.33
+++ jsm/deliver.c	4 Jun 2002 17:40:34 -0000	1.35
@@ -90,6 +90,7 @@
     session s = NULL;
     udata u;
     char *type, *authto;
+    xmlnode child;
 
     log_debug(ZONE,"(%X)incoming packet %s",si,xmlnode2str(p->x));
 
@@ -127,9 +128,17 @@
             return r_DONE;
         }
 
-        /* get the internal jpacket */
-        if(xmlnode_get_firstchild(p->x) != NULL) /* XXX old libjabber jpacket_new() wasn't null safe, this is just safety */
-            jp = jpacket_new(xmlnode_get_firstchild(p->x));
+        /* Find the first real element */
+        child = xmlnode_get_firstchild(p->x);
+        while (child != NULL)
+        {
+            if (xmlnode_get_type(child) == NTYPE_TAG)
+                break;
+            child = xmlnode_get_nextsibling(child);
+        }
+        /* As long as we found one process */
+        if (child != NULL)
+            jp = jpacket_new(child);
 
         /* auth/reg requests */
         if(jp != NULL && j_strcmp(type,"auth") == 0)
