Nmap Development mailing list archives

Revised patch for intf-win32.c in NMAP-6.01


From: Bill Parker <wp02855 () gmail com>
Date: Fri, 23 Nov 2012 08:59:36 -0800

Hello All,

   In reviewing intf-win32.c in 'nmap-6.01/libdnet-stripped/src',
per David Fifield, it would appear that '_ifcombo_add' is not
called by any other routine in the NMAP-6.01 source tree (via a
grep -r "_ifcombo_add" *) from the nmap-6.01 top level directory.

I would agree that _ifcombo_add should return a value indicating
failure or success, but if there is no corresponding call to
_ifcombo_add in the NMAP-6.01 source tree, should this code even
included, given that intf-win32.c is not even compiled under
linux or *BSD when a 'make' or 'make all' is issued?

Here is a revised patch file for intf-win32.c to eliminate the
fprintf calls in the event realloc() or malloc() returns NULL:

--- intf-win32.c.orig   2012-11-22 07:22:39.276999867 -0800
+++ intf-win32.c        2012-11-22 07:26:50.288999323 -0800
@@ -94,9 +94,17 @@
                        ifc->max *= 2;
                        ifc->idx = realloc(ifc->idx,
                            sizeof(ifc->idx[0]) * ifc->max);
+                       if (ifc->idx == NULL) {
+                                perror("warning: call to realloc() failed,
original buffer unchanged.\n");
+                                return;
+                        }
                } else {
                        ifc->max = 8;
                        ifc->idx = malloc(sizeof(ifc->idx[0]) * ifc->max);
+                       if (ifc->idx == NULL) {
+                                perror("warning: memory allocation failed
in function '_ifcombo_add'\n");
+                                return;
+                        }
                }
        }
        ifc->idx[ifc->cnt].ipv4 = ipv4_idx;
The patch file is attached to this email.

Bill Parker (wp02855 at gmail dot com)

Attachment: intf-win32.c.patch
Description:

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/

Current thread: