1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

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

This commit is contained in:
fyodor
2007-08-11 05:57:54 +00:00
parent 7aede51c1d
commit 03b4dc0ec5
5 changed files with 12 additions and 16 deletions

14
nmap.cc
View File

@@ -2430,7 +2430,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) {
ftp->server_name, ftp->port); ftp->server_name, ftp->port);
if ((sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { 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; return 0;
} }
@@ -2448,8 +2448,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) {
log_write(LOG_STDOUT, "%s", recvbuf); log_write(LOG_STDOUT, "%s", recvbuf);
} }
if (res < 0) { if (res < 0) {
perror("recv problem from ftp bounce server"); pfatal("recv problem from ftp bounce server");
exit(1);
} }
snprintf(command, 511, "USER %s\r\n", ftp->user); 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); send(sd, command, strlen(command), 0);
res = recvtime(sd, recvbuf, sizeof(recvbuf) - 1,12, NULL); res = recvtime(sd, recvbuf, sizeof(recvbuf) - 1,12, NULL);
if (res <= 0) { if (res <= 0) {
perror("recv problem from ftp bounce server"); pfatal("recv problem from ftp bounce server");
exit(1);
} }
recvbuf[res] = '\0'; recvbuf[res] = '\0';
if (o.debugging) log_write(LOG_STDOUT, "sent username, received: %s", recvbuf); 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); send(sd, command, strlen(command), 0);
res = recvtime(sd, recvbuf, sizeof(recvbuf) - 1,12, NULL); res = recvtime(sd, recvbuf, sizeof(recvbuf) - 1,12, NULL);
if (res < 0) { if (res < 0) {
perror("recv problem from ftp bounce server\n"); pfatal("recv problem from ftp bounce server");
exit(1);
} }
if (!res) error("Timeout from bounce server ..."); if (!res) error("Timeout from bounce server ...");
else { else {
@@ -2489,8 +2486,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) {
log_write(LOG_STDOUT, "%s", recvbuf); log_write(LOG_STDOUT, "%s", recvbuf);
} }
if (res < 0) { if (res < 0) {
perror("recv problem from ftp bounce server"); pfatal("recv problem from ftp bounce server");
exit(1);
} }
if (o.verbose) log_write(LOG_STDOUT, "Login credentials accepted by ftp server!\n"); if (o.verbose) log_write(LOG_STDOUT, "Login credentials accepted by ftp server!\n");

View File

@@ -210,7 +210,7 @@ for(decoy=0; decoy < o.numdecoys; decoy++) {
if ((res = send_ip_packet(sd, eth, packet, ntohs(ip->ip_len))) == -1) 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; return NULL;
} }
} }

View File

@@ -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) 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; return 1;
} }
} }

View File

@@ -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); snprintf(command, 512, "PORT %s%i,%i\r\n", targetstr, p1,p2);
if (o.debugging) log_write(LOG_STDOUT, "Attempting command: %s", command); if (o.debugging) log_write(LOG_STDOUT, "Attempting command: %s", command);
if (send(sd, command, strlen(command), 0) < 0 ) { if (send(sd, command, strlen(command), 0) < 0 ) {
perror("send in bounce_scan"); gh_perror("send in %s", __func__);
if (retriesleft) { if (retriesleft) {
if (o.verbose || o.debugging) if (o.verbose || o.debugging)
log_write(LOG_STDOUT, "Our ftp proxy server hung up on us! retrying\n"); 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 */ } else { /* Our send is good */
res = recvtime(sd, recvbuf, 2048, 15, NULL); res = recvtime(sd, recvbuf, 2048, 15, NULL);
if (res <= 0) if (res <= 0)
perror("recv problem from ftp bounce server\n"); perror("recv problem from ftp bounce server");
else { /* our recv is good */ else { /* our recv is good */
recvbuf[res] = '\0'; 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 ) { if (send(sd, "LIST\r\n", 6, 0) > 0 ) {
res = recvtime(sd, recvbuf, 2048,12, &timedout); res = recvtime(sd, recvbuf, 2048,12, &timedout);
if (res < 0) { if (res < 0) {
perror("recv problem from ftp bounce server\n"); perror("recv problem from ftp bounce server");
} else if (res == 0) { } else if (res == 0) {
if (timedout) if (timedout)
target->ports.addPort(portarray[i], IPPROTO_TCP, NULL, target->ports.addPort(portarray[i], IPPROTO_TCP, NULL,

View File

@@ -3235,14 +3235,14 @@ int recvtime(int sd, char *buf, int len, int seconds, int *timedout) {
if (res > 0 ) { if (res > 0 ) {
res = recv(sd, buf, len, 0); res = recv(sd, buf, len, 0);
if (res >= 0) return res; if (res >= 0) return res;
perror("recv in recvtime"); gh_perror("recv in %s", __func__);
return 0; return 0;
} }
else if (!res) { else if (!res) {
if (timedout) *timedout = 1; if (timedout) *timedout = 1;
return 0; return 0;
} }
perror("select() in recvtime"); gh_perror("select() in %s", __func__);
return -1; return -1;
} }