summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/res_debug.c
diff options
context:
space:
mode:
authorderaadt <>2002-05-24 21:22:37 +0000
committerderaadt <>2002-05-24 21:22:37 +0000
commit2be7fb6fb1368b131cd6a8f7ee34d9c11ef25a64 (patch)
tree96f82217a2fd5234ac1e25601237e64983eef146 /src/lib/libc/net/res_debug.c
parent4bb76773d7dd0051cb98a137db9aeefb61518f5a (diff)
downloadopenbsd-2be7fb6fb1368b131cd6a8f7ee34d9c11ef25a64.tar.gz
openbsd-2be7fb6fb1368b131cd6a8f7ee34d9c11ef25a64.tar.bz2
openbsd-2be7fb6fb1368b131cd6a8f7ee34d9c11ef25a64.zip
try to use strlcpy and snprintf more; ok various
Diffstat (limited to 'src/lib/libc/net/res_debug.c')
-rw-r--r--src/lib/libc/net/res_debug.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/lib/libc/net/res_debug.c b/src/lib/libc/net/res_debug.c
index 54be69cef7..75d70e86b6 100644
--- a/src/lib/libc/net/res_debug.c
+++ b/src/lib/libc/net/res_debug.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: res_debug.c,v 1.11 2001/06/11 10:05:59 itojun Exp $ */ 1/* $OpenBSD: res_debug.c,v 1.12 2002/05/24 21:22:37 deraadt Exp $ */
2 2
3/* 3/*
4 * ++Copyright++ 1985, 1990, 1993 4 * ++Copyright++ 1985, 1990, 1993
@@ -82,7 +82,7 @@
82static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; 82static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
83static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $"; 83static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $";
84#else 84#else
85static char rcsid[] = "$OpenBSD: res_debug.c,v 1.11 2001/06/11 10:05:59 itojun Exp $"; 85static char rcsid[] = "$OpenBSD: res_debug.c,v 1.12 2002/05/24 21:22:37 deraadt Exp $";
86#endif 86#endif
87#endif /* LIBC_SCCS and not lint */ 87#endif /* LIBC_SCCS and not lint */
88 88
@@ -159,7 +159,9 @@ dewks(wks)
159 case 161: return "snmp"; 159 case 161: return "snmp";
160 case 162: return "snmp-trap"; 160 case 162: return "snmp-trap";
161 case 170: return "print-srv"; 161 case 170: return "print-srv";
162 default: (void) sprintf(nbuf, "%d", wks); return (nbuf); 162 default:
163 (void) snprintf(nbuf, sizeof nbuf, "%d", wks);
164 return (nbuf);
163 } 165 }
164} 166}
165 167
@@ -183,7 +185,9 @@ deproto(protonum)
183 case 12: return "pup"; 185 case 12: return "pup";
184 case 16: return "chaos"; 186 case 16: return "chaos";
185 case 17: return "udp"; 187 case 17: return "udp";
186 default: (void) sprintf(nbuf, "%d", protonum); return (nbuf); 188 default:
189 (void) snprintf(nbuf, sizeof nbuf, "%d", protonum);
190 return (nbuf);
187 } 191 }
188} 192}
189 193
@@ -436,7 +440,7 @@ __p_fqnname(cp, msg, msglen, name, namelen)
436 440
437 if ((n = dn_expand(msg, cp + msglen, cp, name, namelen)) < 0) 441 if ((n = dn_expand(msg, cp + msglen, cp, name, namelen)) < 0)
438 return (NULL); 442 return (NULL);
439 newlen = strlen (name); 443 newlen = strlen(name);
440 if (newlen == 0 || name[newlen - 1] != '.') { 444 if (newlen == 0 || name[newlen - 1] != '.') {
441 if (newlen+1 >= namelen) /* Lack space for final dot */ 445 if (newlen+1 >= namelen) /* Lack space for final dot */
442 return (NULL); 446 return (NULL);
@@ -958,7 +962,7 @@ __sym_ntos(syms, number, success)
958 } 962 }
959 } 963 }
960 964
961 sprintf (unname, "%d", number); 965 snprintf(unname, sizeof unname, "%d", number);
962 if (success) 966 if (success)
963 *success = 0; 967 *success = 0;
964 return (unname); 968 return (unname);
@@ -980,7 +984,7 @@ __sym_ntop(syms, number, success)
980 return (syms->humanname); 984 return (syms->humanname);
981 } 985 }
982 } 986 }
983 sprintf(unname, "%d", number); 987 snprintf(unname, sizeof unname, "%d", number);
984 if (success) 988 if (success)
985 *success = 0; 989 *success = 0;
986 return (unname); 990 return (unname);
@@ -1030,8 +1034,9 @@ __p_option(option)
1030 case RES_INSECURE2: return "insecure2"; 1034 case RES_INSECURE2: return "insecure2";
1031 case RES_USE_INET6: return "inet6"; 1035 case RES_USE_INET6: return "inet6";
1032 case RES_USE_EDNS0: return "edns0"; 1036 case RES_USE_EDNS0: return "edns0";
1033 default: sprintf(nbuf, "?0x%lx?", (u_long)option); 1037 default:
1034 return (nbuf); 1038 snprintf(nbuf, sizeof nbuf, "?0x%lx?", (u_long)option);
1039 return (nbuf);
1035 } 1040 }
1036} 1041}
1037 1042
@@ -1047,7 +1052,7 @@ p_time(value)
1047 register char *p; 1052 register char *p;
1048 1053
1049 if (value == 0) { 1054 if (value == 0) {
1050 strcpy(nbuf, "0 secs"); 1055 strlcpy(nbuf, "0 secs", sizeof nbuf);
1051 return (nbuf); 1056 return (nbuf);
1052 } 1057 }
1053 1058
@@ -1109,7 +1114,7 @@ precsize_ntoa(prec)
1109 1114
1110 val = mantissa * poweroften[exponent]; 1115 val = mantissa * poweroften[exponent];
1111 1116
1112 (void) sprintf(retbuf, "%ld.%.2ld", val/100, val%100); 1117 (void) snprintf(retbuf, sizeof retbuf, "%ld.%.2ld", val/100, val%100);
1113 return (retbuf); 1118 return (retbuf);
1114} 1119}
1115 1120
@@ -1513,7 +1518,7 @@ __p_secstodate (secs)
1513 time = gmtime(&clock); 1518 time = gmtime(&clock);
1514 time->tm_year += 1900; 1519 time->tm_year += 1900;
1515 time->tm_mon += 1; 1520 time->tm_mon += 1;
1516 sprintf(output, "%04d%02d%02d%02d%02d%02d", 1521 snprintf(output, sizeof output, "%04d%02d%02d%02d%02d%02d",
1517 time->tm_year, time->tm_mon, time->tm_mday, 1522 time->tm_year, time->tm_mon, time->tm_mday,
1518 time->tm_hour, time->tm_min, time->tm_sec); 1523 time->tm_hour, time->tm_min, time->tm_sec);
1519 return (output); 1524 return (output);