diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index ff7279e52..19fe0ab12 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -4722,7 +4722,7 @@ int set_max_open_descriptors(int desired_max) { if (!getrlimit(flag, &r)) { /* If current limit is less than the desired, try to increase it */ - if(r.rlim_cur < (rlim_t)desired_max){ + if(r.rlim_cur != RLIM_INFINITY && r.rlim_cur < (rlim_t)desired_max){ if(desired_max<0){ r.rlim_cur=r.rlim_max; /* Set maximum */ }else{ @@ -4732,6 +4732,7 @@ int set_max_open_descriptors(int desired_max) { ; // netutil_debug("setrlimit(%d, %p) failed", flag, r); if (!getrlimit(flag, &r)) { maxfds = r.rlim_cur; + // NOTE: This may be RLIM_INFINITY, which is -1 (~0UL) on Linux. return maxfds; }else { return 0; diff --git a/nmap.cc b/nmap.cc index 630d43bd7..bad1d53b3 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1994,8 +1994,8 @@ int nmap_main(int argc, char *argv[]) { SIGPIPE */ #endif - if (o.max_parallelism && (i = max_sd()) && i < o.max_parallelism) { - error("WARNING: Your specified max_parallel_sockets of %d, but your system says it might only give us %d. Trying anyway", o.max_parallelism, i); + if (o.max_parallelism && (i = max_sd()) > 0 && i < o.max_parallelism) { + error("WARNING: max_parallelism is %d, but your system says it might only give us %d sockets. Trying anyway", o.max_parallelism, i); } if (o.debugging > 1)