Nmap Development mailing list archives

[NmapFE PATCH] Remove some bogus if (...) realloc() code from nmapfe_sig.c


From: Kris Katterjohn <kjak () ispwest com>
Date: Sun, 01 Oct 2006 21:40:32 -0500

The attached patch removes some weird, unneeded code.

It currently calls realloc(command, 2560) EVERY time the function is
called because command_size never changes. This just calls malloc(2560)
 the first time and removes the extra variables.

It's a diff against 4.20ALPHA8

Thanks,
Kris Katterjohn
--- x/nmapfe/nmapfe_sig.c       2006-09-26 02:49:21.000000000 -0500
+++ y/nmapfe/nmapfe_sig.c       2006-10-01 21:33:37.000000000 -0500
@@ -236,9 +236,7 @@ static char *next_token(char *buf, char 
 
 static char *build_command()
 {
-int size = 2560; /* this should be long enough ;-) */
 static char *command = NULL;
-static int command_size = 0;
 
   /* Find how much to malloc() */
   // size = strlen(gtk_entry_get_text(GTK_ENTRY(opt.range_text))) +
@@ -250,8 +248,8 @@ static int command_size = 0;
   //   2560;
   /* We get 60 from the chars required for each option */
 
-  if (size > command_size)
-    command = realloc(command, size);
+  if (!command)
+    command = malloc(2560); /* this should be long enough ;-) */
 
   strcpy(command, "nmap ");
  

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

Current thread: