[PATCH] KExtendedSocket crashes

Adriaan de Groot adridg at cs.kun.nl
Sat Nov 16 11:02:54 GMT 2002


A FBSD user reported that KSCD with Remote FreeDB enabled crashes if you have 
no network configured on the system. I hunted this down to a NULL pointer 
dereference in KExtendedSocket::connect(). 


If name resolution fails and sets d->resolution to NULL, lookup()
returns as if it did succeed. SO in connect() when "things are a little 
tricky", using d->resolution->data (kextsock.cpp:1211) crashes. 
Fix there or in connect()? Or in listen()?

THis diff is a fix in lookup() that fakes some stuff:

Index: kextsock.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kextsock.cpp,v
retrieving revision 1.36.2.2
diff -r1.36.2.2 kextsock.cpp
914a915,920
>
>       if (d->resolution == NULL)
>         {
>         setError(IO_LookupError,EAGAIN);
>         return -1;
>       }

I don't know if this affects passive sockets. Perhaps it needs a fix in 
connect() in which case the patch is 

@@ -1174,7 +1180,8 @@
   if (d->status < lookupDone)
     if (lookup() < 0)
       return -2;
-
+  if (!d->resolution) return -2;
+
   addrinfo *p, *q;
   timeval end, now;
   // Ok, things are a little tricky here


OK to commit to BRANCH? Useful to commit to HEAD? Bandwidth is a little short 
here, I can't suck down HEAD to check how things are there.

In other news:

KExtendedSocket::lookup() is documented to return 0 on success,
non 0 on failure, but the code elsewhere in KExtendedSocket checks
for error returns < 0.





More information about the kde-core-devel mailing list