Nmap Development mailing list archives

Re: --excludefile bug


From: "Henri Doreau" <henri.doreau () gmail com>
Date: Wed, 14 Jan 2009 21:58:13 +0100

Hello,

I wrote a trivial patch to fix this behavior, this seems to work now.


Regards

Henri


--- targets.cc  2009-01-14 21:42:45.000000000 +0100
+++ targets_excludefile_fixed.cc        2009-01-14 21:53:54.000000000 +0100
@@ -283,7 +283,8 @@
    * in the file, and reset the file */
   if (1 == b_file) {
     while ((char *)0 != fgets(acBuf,sizeof(acBuf), fExclude)) {
-      if ((char *)0 == strchr(acBuf, '\n')) {
+      /* the last line can contain no newline, then we have to check for EOF */
+      if ((char *)0 == strchr(acBuf, '\n') && !feof(fExclude)) {
         fatal("Exclude file line %d was too long to read.  Exiting.", iLine);
       }
       pc=strtok(acBuf, "\t\n ");       
@@ -317,7 +318,7 @@
     /* If we are parsing a file load the exclude list from that */
     while ((char *)0 != fgets(acBuf, sizeof(acBuf), fExclude)) {
       ++iLine;
-      if ((char *)0 == strchr(acBuf, '\n')) {
+      if ((char *)0 == strchr(acBuf, '\n') && !feof(fExclude)) {
         fatal("Exclude file line %d was too long to read.  Exiting.", iLine);
       }

Attachment: targets.cc.patch
Description:


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

Current thread: