]> granicus.if.org Git - curl/commitdiff
multi.c: fix possible invalid memory access in case nfds overflows
authorMarc Hoersken <info@marc-hoersken.de>
Sat, 19 Apr 2014 14:02:14 +0000 (16:02 +0200)
committerMarc Hoersken <info@marc-hoersken.de>
Sat, 19 Apr 2014 14:02:14 +0000 (16:02 +0200)
ufds might not be allocated in case nfds overflows to zero while
extra_nfds is still non-zero. udfs is then accessed within the
extra_nfds-based for loop.

lib/multi.c

index bc69996e67ade04b3cff1f8debf5443041316ebf..bc932640ac9acba6a1499c2a6d776cf7f35c8f13 100644 (file)
@@ -828,7 +828,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
   curlfds = nfds; /* number of internal file descriptors */
   nfds += extra_nfds; /* add the externally provided ones */
 
-  if(nfds) {
+  if(nfds || extra_nfds) {
     ufds = malloc(nfds * sizeof(struct pollfd));
     if(!ufds)
       return CURLM_OUT_OF_MEMORY;