cURL / Mailing Lists / curl-library / Single Mail

curl-library

Validation of descriptors for FD_SET in curl_multi_fdset

From: Robert Iakobashvili <coroberti_at_gmail.com>
Date: Mon, 27 Nov 2006 14:59:02 +0200

Hi,

When using high number of connections (1000),
frequently renewable, and forgetting to redefine FD_SETSIZE
to a higher value, our function stack has been smashed
after a call to
curl_multi_fdset ().

Could it be worth to add something like this
to curl_multi_fdset function?

diff -Nru curl-7.16.0/lib/multi.c curl-7.16.0-rob/lib/multi.c
--- curl-7.16.0/lib/multi.c 2006-10-23 22:34:56.000000000 +0200
+++ curl-7.16.0-rob/lib/multi.c 2006-11-27 12:11:29.000000000 +0200
@@ -8,7 +8,7 @@
  * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel_at_haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
+ * you should have received as part of this distributionCu. The terms
  * are also available at http://curl.haxx.se/docs/copyright.html.
  *
  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
@@ -730,6 +730,13 @@
     for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) {
       curl_socket_t s = CURL_SOCKET_BAD;

+ if ((sockbunch[i] < 0) || (sockbunch[i] >= FD_SETSIZE))
+ {
+ //fprintf (stderr, "%d ",
+ // sockbunch[i]);
+ break;
+ }
+
       if(bitmap & GETSOCK_READSOCK(i)) {
         FD_SET(sockbunch[i], read_fd_set);
         s = sockbunch[i];

Thank you.

-- 
Sincerely,
Robert Iakobashvili,
coroberti %x40 gmail %x2e com
...................................................................
Navigare necesse est, vivere non est necesse
...................................................................
http://sourceforge.net/projects/curl-loader
A powerful open-source HTTP/S, FTP/S traffic
generating, loading and testing tool.
Received on 2006-11-27