Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
notizklotz #1
Member since Dec 2005 · 10 posts · Location: Switzerland
Group memberships: Members
Show profile · Link to this post
Subject: IQGrabber.OnIQ() crashes if callback is null
If IQGrabber.SendIq(IQ iq, IqCB cb, object cbArg) is invoked with cb = null, a null reference for the callback is stored for the IQ's ID in the m_grabbing hashtable. This leads to a NullReferenceException at line 76 in IQGrabber.OnIq(object sender, agsXMPP.Xml.Dom.Node e) when the answer for the IQ is received.

IQGrabber.SendIq(IQ iq, IqCB cb, object cbArg) should only register a callback in the hashtable if cb != null. Proposed patch:

Index: IqGrabber.cs
===================================================================
--- IqGrabber.cs    (revision 76)
+++ IqGrabber.cs    (working copy)
@@ -80,12 +80,15 @@
         /// Send an IQ Request and store the object with callback in the Hashtable
         /// </summary>
         public void SendIq(IQ iq, IqCB cb, object cbArg)
-        {           
-            TrackerData td = new TrackerData();
-            td.cb   = cb;
-            td.data = cbArg;               
+        {
+            if (cb != null)
+            {
+                TrackerData td = new TrackerData();
+                td.cb = cb;
+                td.data = cbArg;
 
-            m_grabbing[iq.Id] = td;
+                m_grabbing[iq.Id] = td;
+            }
            
             m_connection.Send(iq);
         }
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
all Grabber classes must be used with callback != null.
Is there place in the Lib where we use it without a callback?
I will add fix anyway and commit it to CVS later.

Alex
Avatar
notizklotz #3
Member since Dec 2005 · 10 posts · Location: Switzerland
Group memberships: Members
Show profile · Link to this post
Yes. MucManager.AcceptDefaultConfiguration(Jid room) calls MucManager.AcceptDefaultConfiguration(Jid room, IqCB cb, object cbArgs) with cb = null. The latter method doesn't check for this and calls IqGrabber with a null callback
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
i see, this is wrong in the MucManager

Fix:

  1. public void AcceptDefaultConfiguration(Jid room, IqCB cb, object cbArgs)
  2.         {
  3.             OwnerIq oIq = new agsXMPP.protocol.x.muc.iq.owner.OwnerIq(IqType.set, room);
  4.             oIq.Query.AddChild(new Data(XDataFormType.submit));
  5.            
  6.             if (cb == null)
  7.                 m_connection.Send(oIq);
  8.             else
  9.                 m_connection.IqGrabber.SendIq(oIq, cb, cbArgs);
  10.         }

The MUC stuff is pretty new. Any comments and feedback is welcome. If you miss something let us know.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS