mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-23 18:14:29 +08:00
Remove the safeputs() function
Use the nd_printzp() function instead.
This commit is contained in:
parent
23be4d1240
commit
e10fe19f45
@ -355,8 +355,6 @@ extern void txtproto_print(netdissect_options *, const u_char *, u_int,
|
||||
#define ND_ISGRAPH(c) ((c) > 0x20 && (c) <= 0x7E)
|
||||
#define ND_TOASCII(c) ((c) & 0x7F)
|
||||
|
||||
extern void safeputs(netdissect_options *, const u_char *, const u_int);
|
||||
|
||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(__x86_64__) || defined(_M_X64)) || \
|
||||
(defined(__arm__) || defined(_M_ARM) || defined(__aarch64__)) || \
|
||||
(defined(__m68k__) && (!defined(__mc68000__) && !defined(__mc68010__))) || \
|
||||
|
@ -404,7 +404,7 @@ cfm_print(netdissect_options *ndo,
|
||||
switch (md_nameformat) {
|
||||
case CFM_CCM_MD_FORMAT_DNS:
|
||||
case CFM_CCM_MD_FORMAT_CHAR:
|
||||
safeputs(ndo, md_name, md_namelength);
|
||||
(void)nd_printzp(ndo, md_name, md_namelength, NULL);
|
||||
break;
|
||||
|
||||
case CFM_CCM_MD_FORMAT_MAC:
|
||||
@ -456,7 +456,7 @@ cfm_print(netdissect_options *ndo,
|
||||
ND_PRINT("\n\t MA Name: ");
|
||||
switch (ma_nameformat) {
|
||||
case CFM_CCM_MA_FORMAT_CHAR:
|
||||
safeputs(ndo, ma_name, ma_namelength);
|
||||
(void)nd_printzp(ndo, ma_name, ma_namelength, NULL);
|
||||
break;
|
||||
|
||||
/* FIXME add printers for those MA formats - hexdump for now */
|
||||
@ -662,7 +662,7 @@ cfm_print(netdissect_options *ndo,
|
||||
case CFM_CHASSIS_ID_LOCAL:
|
||||
case CFM_CHASSIS_ID_CHASSIS_COMPONENT:
|
||||
case CFM_CHASSIS_ID_PORT_COMPONENT:
|
||||
safeputs(ndo, tptr + 1, chassis_id_length);
|
||||
(void)nd_printzp(ndo, tptr + 1, chassis_id_length, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -207,14 +207,14 @@ eap_print(netdissect_options *ndo,
|
||||
case EAP_TYPE_IDENTITY:
|
||||
if (len - 5 > 0) {
|
||||
ND_PRINT(", Identity: ");
|
||||
safeputs(ndo, tptr + 5, len - 5);
|
||||
(void)nd_printzp(ndo, tptr + 5, len - 5, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case EAP_TYPE_NOTIFICATION:
|
||||
if (len - 5 > 0) {
|
||||
ND_PRINT(", Notification: ");
|
||||
safeputs(ndo, tptr + 5, len - 5);
|
||||
(void)nd_printzp(ndo, tptr + 5, len - 5, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
12
print-hncp.c
12
print-hncp.c
@ -251,11 +251,11 @@ print_dns_label(netdissect_options *ndo,
|
||||
ND_PRINT(".");
|
||||
if (length+lab_length > max_length) {
|
||||
if (print)
|
||||
safeputs(ndo, cp+length, max_length-length);
|
||||
(void)nd_printzp(ndo, cp+length, max_length-length, NULL);
|
||||
break;
|
||||
}
|
||||
if (print)
|
||||
safeputs(ndo, cp+length, lab_length);
|
||||
(void)nd_printzp(ndo, cp+length, lab_length, NULL);
|
||||
length += lab_length;
|
||||
}
|
||||
if (print)
|
||||
@ -585,7 +585,7 @@ hncp_print_rec(netdissect_options *ndo,
|
||||
ND_PRINT(" Verdict: %u Fingerprint: %s Common Name: ",
|
||||
EXTRACT_U_1(value),
|
||||
format_256(value + 4));
|
||||
safeputs(ndo, value + 36, bodylen - 36);
|
||||
(void)nd_printzp(ndo, value + 36, bodylen - 36, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -604,7 +604,7 @@ hncp_print_rec(netdissect_options *ndo,
|
||||
ND_PRINT(" M: %u P: %u H: %u L: %u User-agent: ",
|
||||
M, P, H, L
|
||||
);
|
||||
safeputs(ndo, value + 4, bodylen - 4);
|
||||
(void)nd_printzp(ndo, value + 4, bodylen - 4, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -689,7 +689,7 @@ hncp_print_rec(netdissect_options *ndo,
|
||||
print_dns_label(ndo, value+1, bodylen-1, 1);
|
||||
} else if (policy == 130) {
|
||||
ND_PRINT("Opaque UTF-8: ");
|
||||
safeputs(ndo, value + 1, bodylen - 1);
|
||||
(void)nd_printzp(ndo, value + 1, bodylen - 1, NULL);
|
||||
} else if (policy == 131) {
|
||||
if (bodylen != 1) {
|
||||
ND_PRINT(" %s", istr);
|
||||
@ -819,7 +819,7 @@ hncp_print_rec(netdissect_options *ndo,
|
||||
);
|
||||
if (l < 64) {
|
||||
ND_PRINT("\"");
|
||||
safeputs(ndo, value + 17, l);
|
||||
(void)nd_printzp(ndo, value + 17, l, NULL);
|
||||
ND_PRINT("\"");
|
||||
} else {
|
||||
ND_PRINT("%s", istr);
|
||||
|
24
print-lldp.c
24
print-lldp.c
@ -699,7 +699,7 @@ lldp_private_8021_print(netdissect_options *ndo,
|
||||
return hexdump;
|
||||
}
|
||||
ND_PRINT("\n\t vlan name: ");
|
||||
safeputs(ndo, tptr + 7, sublen);
|
||||
(void)nd_printzp(ndo, tptr + 7, sublen, NULL);
|
||||
break;
|
||||
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY:
|
||||
if (tlv_len < 5) {
|
||||
@ -710,7 +710,7 @@ lldp_private_8021_print(netdissect_options *ndo,
|
||||
return hexdump;
|
||||
}
|
||||
ND_PRINT("\n\t protocol identity: ");
|
||||
safeputs(ndo, tptr + 5, sublen);
|
||||
(void)nd_printzp(ndo, tptr + 5, sublen, NULL);
|
||||
break;
|
||||
case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION:
|
||||
if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH){
|
||||
@ -1068,7 +1068,7 @@ lldp_private_tia_print(netdissect_options *ndo,
|
||||
EXTRACT_U_1(tptr + 6));
|
||||
|
||||
/* Country code */
|
||||
safeputs(ndo, tptr + 7, 2);
|
||||
(void)nd_printzp(ndo, tptr + 7, 2, NULL);
|
||||
|
||||
lci_len = lci_len-3;
|
||||
tptr = tptr + 9;
|
||||
@ -1096,7 +1096,7 @@ lldp_private_tia_print(netdissect_options *ndo,
|
||||
return hexdump;
|
||||
}
|
||||
|
||||
safeputs(ndo, tptr, ca_len);
|
||||
(void)nd_printzp(ndo, tptr, ca_len, NULL);
|
||||
tptr += ca_len;
|
||||
lci_len -= ca_len;
|
||||
}
|
||||
@ -1104,7 +1104,7 @@ lldp_private_tia_print(netdissect_options *ndo,
|
||||
|
||||
case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN:
|
||||
ND_PRINT("\n\t ECS ELIN id ");
|
||||
safeputs(ndo, tptr + 5, tlv_len - 5);
|
||||
(void)nd_printzp(ndo, tptr + 5, tlv_len - 5, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1141,7 +1141,7 @@ lldp_private_tia_print(netdissect_options *ndo,
|
||||
case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID:
|
||||
ND_PRINT("\n\t %s ",
|
||||
tok2str(lldp_tia_inventory_values, "unknown", subtype));
|
||||
safeputs(ndo, tptr + 4, tlv_len - 4);
|
||||
(void)nd_printzp(ndo, tptr + 4, tlv_len - 4, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1421,7 +1421,7 @@ lldp_mgmt_addr_tlv_print(netdissect_options *ndo,
|
||||
}
|
||||
if (oid_len) {
|
||||
ND_PRINT("\n\t OID length %u", oid_len);
|
||||
safeputs(ndo, tptr + 1, oid_len);
|
||||
(void)nd_printzp(ndo, tptr + 1, oid_len, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1498,7 +1498,7 @@ lldp_print(netdissect_options *ndo,
|
||||
case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE:
|
||||
case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE:
|
||||
case LLDP_CHASSIS_PORT_COMP_SUBTYPE:
|
||||
safeputs(ndo, tptr + 1, tlv_len - 1);
|
||||
(void)nd_printzp(ndo, tptr + 1, tlv_len - 1, NULL);
|
||||
break;
|
||||
|
||||
case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
|
||||
@ -1539,7 +1539,7 @@ lldp_print(netdissect_options *ndo,
|
||||
case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE:
|
||||
case LLDP_PORT_INTF_ALIAS_SUBTYPE:
|
||||
case LLDP_PORT_PORT_COMP_SUBTYPE:
|
||||
safeputs(ndo, tptr + 1, tlv_len - 1);
|
||||
(void)nd_printzp(ndo, tptr + 1, tlv_len - 1, NULL);
|
||||
break;
|
||||
|
||||
case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
|
||||
@ -1569,7 +1569,7 @@ lldp_print(netdissect_options *ndo,
|
||||
case LLDP_PORT_DESCR_TLV:
|
||||
if (ndo->ndo_vflag) {
|
||||
ND_PRINT(": ");
|
||||
safeputs(ndo, tptr, tlv_len);
|
||||
(void)nd_printzp(ndo, tptr, tlv_len, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1579,13 +1579,13 @@ lldp_print(netdissect_options *ndo,
|
||||
* similar to the CDP printer.
|
||||
*/
|
||||
ND_PRINT(": ");
|
||||
safeputs(ndo, tptr, tlv_len);
|
||||
(void)nd_printzp(ndo, tptr, tlv_len, NULL);
|
||||
break;
|
||||
|
||||
case LLDP_SYSTEM_DESCR_TLV:
|
||||
if (ndo->ndo_vflag) {
|
||||
ND_PRINT("\n\t ");
|
||||
safeputs(ndo, tptr, tlv_len);
|
||||
(void)nd_printzp(ndo, tptr, tlv_len, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1168,7 +1168,7 @@ ospf_print(netdissect_options *ndo,
|
||||
|
||||
case OSPF_AUTH_SIMPLE:
|
||||
ND_PRINT("\n\tSimple text password: ");
|
||||
safeputs(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
|
||||
(void)nd_printzp(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN, NULL);
|
||||
break;
|
||||
|
||||
case OSPF_AUTH_MD5:
|
||||
|
@ -188,7 +188,7 @@ vqp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
|
||||
case VQP_OBJ_VLAN_NAME:
|
||||
case VQP_OBJ_VTP_DOMAIN:
|
||||
case VQP_OBJ_ETHERNET_PKT:
|
||||
safeputs(ndo, tptr, vqp_obj_len);
|
||||
(void)nd_printzp(ndo, tptr, vqp_obj_len, NULL);
|
||||
break;
|
||||
/* those objects have similar semantics - fall through */
|
||||
case VQP_OBJ_MAC_ADDRESS:
|
||||
|
13
util-print.c
13
util-print.c
@ -902,19 +902,6 @@ txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
safeputs(netdissect_options *ndo,
|
||||
const u_char *s, const u_int maxlen)
|
||||
{
|
||||
u_int idx = 0;
|
||||
|
||||
while (idx < maxlen && EXTRACT_U_1(s)) {
|
||||
fn_print_char(ndo, EXTRACT_U_1(s));
|
||||
idx++;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(__x86_64__) || defined(_M_X64)) || \
|
||||
(defined(__arm__) || defined(_M_ARM) || defined(__aarch64__)) || \
|
||||
(defined(__m68k__) && (!defined(__mc68000__) && !defined(__mc68010__))) || \
|
||||
|
Loading…
Reference in New Issue
Block a user