From 03b4dc0ec59b4d52aecf7eff42b901bfd79c25ea Mon Sep 17 00:00:00 2001 From: fyodor Date: Sat, 11 Aug 2007 05:57:54 +0000 Subject: [PATCH] merge soc07 r5233 - Changed perror()s with hardcoded function names to Nmap's gh_perror() and __func__, changed perror()s followed by exit()s to Nmap's pfatal(), and removed newlines from perror()s because it breaks the line after that and before the colon and error string, which doesn't make sense --- nmap.cc | 14 +++++--------- osscan.cc | 2 +- osscan2.cc | 2 +- scan_engine.cc | 6 +++--- tcpip.cc | 4 ++-- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/nmap.cc b/nmap.cc index bc81db40d..598d028b1 100644 --- a/nmap.cc +++ b/nmap.cc @@ -2430,7 +2430,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) { ftp->server_name, ftp->port); if ((sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - perror("Couldn't create ftp_anon_connect socket"); + gh_perror("Couldn't create %s socket", __func__); return 0; } @@ -2448,8 +2448,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) { log_write(LOG_STDOUT, "%s", recvbuf); } if (res < 0) { - perror("recv problem from ftp bounce server"); - exit(1); + pfatal("recv problem from ftp bounce server"); } snprintf(command, 511, "USER %s\r\n", ftp->user); @@ -2457,8 +2456,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) { send(sd, command, strlen(command), 0); res = recvtime(sd, recvbuf, sizeof(recvbuf) - 1,12, NULL); if (res <= 0) { - perror("recv problem from ftp bounce server"); - exit(1); + pfatal("recv problem from ftp bounce server"); } recvbuf[res] = '\0'; if (o.debugging) log_write(LOG_STDOUT, "sent username, received: %s", recvbuf); @@ -2471,8 +2469,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) { send(sd, command, strlen(command), 0); res = recvtime(sd, recvbuf, sizeof(recvbuf) - 1,12, NULL); if (res < 0) { - perror("recv problem from ftp bounce server\n"); - exit(1); + pfatal("recv problem from ftp bounce server"); } if (!res) error("Timeout from bounce server ..."); else { @@ -2489,8 +2486,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) { log_write(LOG_STDOUT, "%s", recvbuf); } if (res < 0) { - perror("recv problem from ftp bounce server"); - exit(1); + pfatal("recv problem from ftp bounce server"); } if (o.verbose) log_write(LOG_STDOUT, "Login credentials accepted by ftp server!\n"); diff --git a/osscan.cc b/osscan.cc index ea4ff71b5..777a8feaf 100644 --- a/osscan.cc +++ b/osscan.cc @@ -210,7 +210,7 @@ for(decoy=0; decoy < o.numdecoys; decoy++) { if ((res = send_ip_packet(sd, eth, packet, ntohs(ip->ip_len))) == -1) { - perror("send_ip_packet in send_closedupd_probe"); + gh_perror("send_ip_packet in %s", __func__); return NULL; } } diff --git a/osscan2.cc b/osscan2.cc index de347f235..216db02d1 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -3105,7 +3105,7 @@ int send_closedudp_probe_2(struct udpprobeinfo &upi, int sd, if ((res = send_ip_packet(sd, eth, packet, ntohs(ip->ip_len))) == -1) { - perror("send_ip_packet in send_closedupd_probe_2"); + gh_perror("send_ip_packet in %s", __func__); return 1; } } diff --git a/scan_engine.cc b/scan_engine.cc index 21b057f56..1dc90cf30 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -3560,7 +3560,7 @@ void bounce_scan(Target *target, u16 *portarray, int numports, snprintf(command, 512, "PORT %s%i,%i\r\n", targetstr, p1,p2); if (o.debugging) log_write(LOG_STDOUT, "Attempting command: %s", command); if (send(sd, command, strlen(command), 0) < 0 ) { - perror("send in bounce_scan"); + gh_perror("send in %s", __func__); if (retriesleft) { if (o.verbose || o.debugging) log_write(LOG_STDOUT, "Our ftp proxy server hung up on us! retrying\n"); @@ -3580,7 +3580,7 @@ void bounce_scan(Target *target, u16 *portarray, int numports, } else { /* Our send is good */ res = recvtime(sd, recvbuf, 2048, 15, NULL); if (res <= 0) - perror("recv problem from ftp bounce server\n"); + perror("recv problem from ftp bounce server"); else { /* our recv is good */ recvbuf[res] = '\0'; @@ -3602,7 +3602,7 @@ void bounce_scan(Target *target, u16 *portarray, int numports, if (send(sd, "LIST\r\n", 6, 0) > 0 ) { res = recvtime(sd, recvbuf, 2048,12, &timedout); if (res < 0) { - perror("recv problem from ftp bounce server\n"); + perror("recv problem from ftp bounce server"); } else if (res == 0) { if (timedout) target->ports.addPort(portarray[i], IPPROTO_TCP, NULL, diff --git a/tcpip.cc b/tcpip.cc index bdda45c32..dca0cc936 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -3235,14 +3235,14 @@ int recvtime(int sd, char *buf, int len, int seconds, int *timedout) { if (res > 0 ) { res = recv(sd, buf, len, 0); if (res >= 0) return res; - perror("recv in recvtime"); + gh_perror("recv in %s", __func__); return 0; } else if (!res) { if (timedout) *timedout = 1; return 0; } - perror("select() in recvtime"); + gh_perror("select() in %s", __func__); return -1; }