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

Correct format string specifiers

The formats has been tested and verified on Mac OS X 10.8.5,
Mac OS X 10.11.5 and Ubuntu 14.04 LTS, all on x86_64 machines
and OSs. It mainly silences warnings. There were no warnings on
Ubuntu but a few on Mac OS, so the fix is intended to silence
warnings on Mac OS whithout triggering new warnings on other OSs.
Example of warnings previously encountered:

netutil.cc:2828:74: warning: format specifies type 'unsigned short'
but the argument has type 'int' [-Wformat]
This commit is contained in:
vincent
2016-07-01 11:44:26 +00:00
parent 9703feace9
commit 0f22680426
6 changed files with 12 additions and 12 deletions

View File

@@ -2825,7 +2825,7 @@ const char *ippackethdrinfo(const u8 *packet, u32 len, int detail) {
case 4: case 4:
strcpy(icmptype, "Fragmentation required"); strcpy(icmptype, "Fragmentation required");
Snprintf(icmpfields, sizeof(icmpfields), "Next-Hop-MTU=%hu", icmppkt->data[2]<<8 | icmppkt->data[3]); Snprintf(icmpfields, sizeof(icmpfields), "Next-Hop-MTU=%d", icmppkt->data[2]<<8 | icmppkt->data[3]);
break; break;
case 5: case 5:

View File

@@ -258,7 +258,7 @@ static void connect_report(nsock_iod nsi)
char digest_buf[SHA1_STRING_LENGTH + 1]; char digest_buf[SHA1_STRING_LENGTH + 1];
char *fp; char *fp;
loguser("SSL connection to %s:%hu.", inet_socktop(&peer), loguser("SSL connection to %s:%d.", inet_socktop(&peer),
nsock_iod_get_peerport(nsi)); nsock_iod_get_peerport(nsi));
cert = SSL_get_peer_certificate((SSL *)nsock_iod_get_ssl(nsi)); cert = SSL_get_peer_certificate((SSL *)nsock_iod_get_ssl(nsi));
@@ -285,7 +285,7 @@ static void connect_report(nsock_iod nsi)
loguser("Connected to %s.\n", peer.un.sun_path); loguser("Connected to %s.\n", peer.un.sun_path);
else else
#endif #endif
loguser("Connected to %s:%hu.\n", inet_socktop(&peer), loguser("Connected to %s:%d.\n", inet_socktop(&peer),
nsock_iod_get_peerport(nsi)); nsock_iod_get_peerport(nsi));
} }
#else #else
@@ -294,7 +294,7 @@ static void connect_report(nsock_iod nsi)
loguser("Connected to %s.\n", peer.un.sun_path); loguser("Connected to %s.\n", peer.un.sun_path);
else else
#endif #endif
loguser("Connected to %s:%hu.\n", inet_socktop(&peer), loguser("Connected to %s:%d.\n", inet_socktop(&peer),
nsock_iod_get_peerport(nsi)); nsock_iod_get_peerport(nsi));
#endif #endif
} }

View File

@@ -492,7 +492,7 @@ static int handle_connect(struct socket_buffer *client_sock,
return 400; return 400;
} }
if (o.debug > 1) if (o.debug > 1)
logdebug("CONNECT to %s:%hu.\n", request->uri.host, request->uri.port); logdebug("CONNECT to %s:%d.\n", request->uri.host, request->uri.port);
rc = resolve(request->uri.host, request->uri.port, &su.storage, &sslen, o.af); rc = resolve(request->uri.host, request->uri.port, &su.storage, &sslen, o.af);
if (rc != 0) { if (rc != 0) {
@@ -680,7 +680,7 @@ static int do_transaction(struct http_request *request,
if (request->uri.port == -1 || request->uri.port == 80) if (request->uri.port == -1 || request->uri.port == 80)
n = Snprintf(buf, sizeof(buf), "%s", request->uri.host); n = Snprintf(buf, sizeof(buf), "%s", request->uri.host);
else else
n = Snprintf(buf, sizeof(buf), "%s:%hu", request->uri.host, request->uri.port); n = Snprintf(buf, sizeof(buf), "%s:%d", request->uri.host, request->uri.port);
if (n < 0 || n >= sizeof(buf)) { if (n < 0 || n >= sizeof(buf)) {
/* Request Entity Too Large. */ /* Request Entity Too Large. */
return 501; return 501;

View File

@@ -3420,7 +3420,7 @@ bool HostOsScan::get_tcpopt_string(struct tcp_hdr *tcp, int mss, char *result, i
break; /* Window Scale option has 3 bytes */ break; /* Window Scale option has 3 bytes */
*p++ = 'W'; *p++ = 'W';
q++; q++;
snprintf(p, length, "%hX", *((u8*)q)); snprintf(p, length, "%hhX", *((u8*)q));
p += strlen(p); /* max movement of p is 2 (max WScale value is 0xFF) */ p += strlen(p); /* max movement of p is 2 (max WScale value is 0xFF) */
q++; q++;
length -= 3; length -= 3;

View File

@@ -1879,7 +1879,7 @@ void printosscanoutput(Target *currenths) {
xml_open_start_tag("portused"); xml_open_start_tag("portused");
xml_attribute("state", "open"); xml_attribute("state", "open");
xml_attribute("proto", "tcp"); xml_attribute("proto", "tcp");
xml_attribute("portid", "%hu", FPR->osscan_opentcpport); xml_attribute("portid", "%d", FPR->osscan_opentcpport);
xml_close_empty_tag(); xml_close_empty_tag();
xml_newline(); xml_newline();
} }
@@ -1887,7 +1887,7 @@ void printosscanoutput(Target *currenths) {
xml_open_start_tag("portused"); xml_open_start_tag("portused");
xml_attribute("state", "closed"); xml_attribute("state", "closed");
xml_attribute("proto", "tcp"); xml_attribute("proto", "tcp");
xml_attribute("portid", "%hu", FPR->osscan_closedtcpport); xml_attribute("portid", "%d", FPR->osscan_closedtcpport);
xml_close_empty_tag(); xml_close_empty_tag();
xml_newline(); xml_newline();
} }
@@ -1895,7 +1895,7 @@ void printosscanoutput(Target *currenths) {
xml_open_start_tag("portused"); xml_open_start_tag("portused");
xml_attribute("state", "closed"); xml_attribute("state", "closed");
xml_attribute("proto", "udp"); xml_attribute("proto", "udp");
xml_attribute("portid", "%hu", FPR->osscan_closedudpport); xml_attribute("portid", "%d", FPR->osscan_closedudpport);
xml_close_empty_tag(); xml_close_empty_tag();
xml_newline(); xml_newline();
} }

View File

@@ -1269,7 +1269,7 @@ int readtcppacket(const u8 *packet, int readdata) {
log_write(LOG_PLAIN, "URG "); log_write(LOG_PLAIN, "URG ");
log_write(LOG_PLAIN, "\n"); log_write(LOG_PLAIN, "\n");
log_write(LOG_PLAIN, "ipid: %hu ttl: %hu ", ntohs(ip->ip_id), log_write(LOG_PLAIN, "ipid: %hu ttl: %hhu ", ntohs(ip->ip_id),
ip->ip_ttl); ip->ip_ttl);
if (tcp->th_flags & (TH_SYN | TH_ACK)) if (tcp->th_flags & (TH_SYN | TH_ACK))
@@ -1329,7 +1329,7 @@ int readudppacket(const u8 *packet, int readdata) {
sourcehost, ntohs(udp->uh_sport), inet_ntoa(bullshit2), sourcehost, ntohs(udp->uh_sport), inet_ntoa(bullshit2),
ntohs(udp->uh_dport), tot_len); ntohs(udp->uh_dport), tot_len);
log_write(LOG_PLAIN, "ttl: %hu ", ip->ip_ttl); log_write(LOG_PLAIN, "ttl: %hhu ", ip->ip_ttl);
} }
} }
if (readdata && i < tot_len) { if (readdata && i < tot_len) {