Nmap Development mailing list archives

[PATCH] Use replacenonprintable() instead of "doing it" in portlist.cc


From: Kris Katterjohn <kjak () ispwest com>
Date: Tue, 22 Aug 2006 12:45:30 -0500

This uses replacenonprintable() from nbase instead of looping and doing
the replacing in cstringSanityCheck() in portlist.cc.

It's a diff against 4.20ALPHA4

Thanks,
Kris Katterjohn
--- x/portlist.cc       2006-07-04 18:05:03.000000000 -0500
+++ y/portlist.cc       2006-08-22 12:37:30.000000000 -0500
@@ -268,7 +268,6 @@ int Port::getServiceDeductions(struct se
 char* Port::cstringSanityCheck(const char* string, int len) {
        char* result;
   int slen;
-  unsigned char *p;
 
   if(!string)
          return NULL;
@@ -278,11 +277,7 @@ char* Port::cstringSanityCheck(const cha
   result = (char *) safe_malloc(slen + 1);
   memcpy(result, string, slen);
   result[slen] = '\0';
-  p = (unsigned char *) result;
-  while(*p) {
-    if (!isprint((int)*p)) *p = '.';
-    p++;
-  }
+  replacenonprintable(result, strlen(result), '.');
 
        return result;
 }

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

Current thread: