]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Remove the safeputs() function
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 2 May 2018 08:01:34 +0000 (10:01 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 2 May 2018 08:15:26 +0000 (10:15 +0200)
Use the nd_printzp() function instead.

netdissect.h
print-cfm.c
print-eap.c
print-hncp.c
print-lldp.c
print-ospf.c
print-vqp.c
util-print.c

index 937c57e124aed599b3abc69c31b5e3cb84791e5b..81c767e1938527f158deab5c389c1da508c67934 100644 (file)
@@ -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__))) || \
index 568e30367d1a0ebe16dbedc4e1e85a9ca8bf4d4b..8b3e3e002b05477a84f1aeceb2815f699b56e56b 100644 (file)
@@ -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:
index a94168228214ca4ee84d013091580a3ad60e489e..6225e9f25d073c8acfb2e4eeb8fb1af3b5d88fc3 100644 (file)
@@ -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;
 
index ab190dd564bb3b8b9c207dd20ade3494efc4dad9..13064678da76c1c3553ebdfc9736c46edcb33a52 100644 (file)
@@ -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);
index 1adbae0dc89b57683fa52c4183f2f2547ed68c49..a200228e4e790e80796b5669c8e2c4420ab0ea00 100644 (file)
@@ -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;
 
index 8907df14b5b36f8d3d2cc3c7eb9807f23acd4949..4c5ba665d5cfa1a8faeb893d4a61c82385c47337 100644 (file)
@@ -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:
index ab00a79961eb7d0044237fcdd7ba9fa3b8634ec2..3e8e011c876b43891b97b61622dd416edfd21147 100644 (file)
@@ -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:
index dc2f532ac95e4642de2e2aa84e2a687fd2df7ff6..1a54a42a1898256cb75ae9c740a898d190e51a3e 100644 (file)
@@ -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__))) || \