]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-snmp.c
s/sprintf/snprintf/.
[tcpdump] / print-snmp.c
index a546d5d722fc94a6e672a2eea4c653cd80130cb0..503fc96799fed38ca386331c13aaccd97d6084ff 100644 (file)
@@ -45,7 +45,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.38 1999-12-13 18:06:14 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.40 2000-01-17 06:24:26 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -188,7 +188,8 @@ char *ErrorStatus[] = {
 };
 #define DECODE_ErrorStatus(e) \
        ( e >= 0 && e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \
-       ? ErrorStatus[e] : (sprintf(errbuf, "err=%u", e), errbuf))
+               ? ErrorStatus[e] \
+               : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
 
 /*
  * generic-trap values in the SNMP Trap-PDU
@@ -205,7 +206,8 @@ char *GenericTrap[] = {
 };
 #define DECODE_GenericTrap(t) \
        ( t >= 0 && t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \
-       ? GenericTrap[t] : (sprintf(buf, "gt=%d", t), buf))
+               ? GenericTrap[t] \
+               : (snprintf(buf, sizeof(buf), "gt=%d", t), buf))
 
 /*
  * ASN.1 type class table
@@ -721,12 +723,21 @@ asn1_print(struct be *elem)
                d = elem->data.uns64.high * 4294967296.0;       /* 2^32 */
                if (elem->data.uns64.high <= 0x1fffff) { 
                        d += elem->data.uns64.low;
+#if 0 /*is looks illegal, but what is the intention???*/
                        printf("%.f", d);
+#else
+                       printf("%f", d);
+#endif
                        break;
                }
                d += (elem->data.uns64.low & 0xfffff000);
-               sprintf(first, "%.f", d);
-               sprintf(last, "%5.5d", elem->data.uns64.low & 0xfff);
+#if 0 /*is looks illegal, but what is the intention???*/
+               snprintf(first, sizeof(first), "%.f", d);
+#else
+               snprintf(first, sizeof(first), "%f", d);
+#endif
+               snprintf(last, sizeof(last), "%5.5d",
+                   elem->data.uns64.low & 0xfff);
                for (carry = 0, cpf = first+strlen(first)-1, cpl = last+4;
                     cpl >= last;
                     cpf--, cpl--) {