diff options
author | deraadt <> | 2002-05-24 21:22:37 +0000 |
---|---|---|
committer | deraadt <> | 2002-05-24 21:22:37 +0000 |
commit | 2be7fb6fb1368b131cd6a8f7ee34d9c11ef25a64 (patch) | |
tree | 96f82217a2fd5234ac1e25601237e64983eef146 /src | |
parent | 4bb76773d7dd0051cb98a137db9aeefb61518f5a (diff) | |
download | openbsd-2be7fb6fb1368b131cd6a8f7ee34d9c11ef25a64.tar.gz openbsd-2be7fb6fb1368b131cd6a8f7ee34d9c11ef25a64.tar.bz2 openbsd-2be7fb6fb1368b131cd6a8f7ee34d9c11ef25a64.zip |
try to use strlcpy and snprintf more; ok various
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/net/ethers.c | 8 | ||||
-rw-r--r-- | src/lib/libc/net/inet_neta.c | 8 | ||||
-rw-r--r-- | src/lib/libc/net/inet_ntop.c | 10 | ||||
-rw-r--r-- | src/lib/libc/net/ipx_ntoa.c | 4 | ||||
-rw-r--r-- | src/lib/libc/net/ns_ntoa.c | 4 | ||||
-rw-r--r-- | src/lib/libc/net/rcmd.c | 5 | ||||
-rw-r--r-- | src/lib/libc/net/res_debug.c | 29 | ||||
-rw-r--r-- | src/lib/libc/net/res_query.c | 7 | ||||
-rw-r--r-- | src/lib/libc/stdlib/realpath.c | 6 |
9 files changed, 43 insertions, 38 deletions
diff --git a/src/lib/libc/net/ethers.c b/src/lib/libc/net/ethers.c index e7781438c1..858ac5b3f3 100644 --- a/src/lib/libc/net/ethers.c +++ b/src/lib/libc/net/ethers.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ethers.c,v 1.13 2002/02/16 21:27:23 millert Exp $ */ | 1 | /* $OpenBSD: ethers.c,v 1.14 2002/05/24 21:22:37 deraadt Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
@@ -34,7 +34,7 @@ | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | #if defined(LIBC_SCCS) && !defined(lint) | 36 | #if defined(LIBC_SCCS) && !defined(lint) |
37 | static char rcsid[] = "$OpenBSD: ethers.c,v 1.13 2002/02/16 21:27:23 millert Exp $"; | 37 | static char rcsid[] = "$OpenBSD: ethers.c,v 1.14 2002/05/24 21:22:37 deraadt Exp $"; |
38 | #endif /* LIBC_SCCS and not lint */ | 38 | #endif /* LIBC_SCCS and not lint */ |
39 | 39 | ||
40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
@@ -72,7 +72,7 @@ ether_ntoa(e) | |||
72 | return (NULL); | 72 | return (NULL); |
73 | } | 73 | } |
74 | 74 | ||
75 | (void)sprintf(a, "%02x:%02x:%02x:%02x:%02x:%02x", | 75 | (void)snprintf(a, sizeof a, "%02x:%02x:%02x:%02x:%02x:%02x", |
76 | e->ether_addr_octet[0], e->ether_addr_octet[1], | 76 | e->ether_addr_octet[0], e->ether_addr_octet[1], |
77 | e->ether_addr_octet[2], e->ether_addr_octet[3], | 77 | e->ether_addr_octet[2], e->ether_addr_octet[3], |
78 | e->ether_addr_octet[4], e->ether_addr_octet[5]); | 78 | e->ether_addr_octet[4], e->ether_addr_octet[5]); |
@@ -138,7 +138,7 @@ ether_ntohost(hostname, e) | |||
138 | } | 138 | } |
139 | 139 | ||
140 | #ifdef YP | 140 | #ifdef YP |
141 | sprintf(trybuf, "%x:%x:%x:%x:%x:%x", | 141 | snprintf(trybuf, sizeof trybuf, "%x:%x:%x:%x:%x:%x", |
142 | e->ether_addr_octet[0], e->ether_addr_octet[1], | 142 | e->ether_addr_octet[0], e->ether_addr_octet[1], |
143 | e->ether_addr_octet[2], e->ether_addr_octet[3], | 143 | e->ether_addr_octet[2], e->ether_addr_octet[3], |
144 | e->ether_addr_octet[4], e->ether_addr_octet[5]); | 144 | e->ether_addr_octet[4], e->ether_addr_octet[5]); |
diff --git a/src/lib/libc/net/inet_neta.c b/src/lib/libc/net/inet_neta.c index ffcddd8d91..881a328ab0 100644 --- a/src/lib/libc/net/inet_neta.c +++ b/src/lib/libc/net/inet_neta.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $ */ | 1 | /* $OpenBSD: inet_neta.c,v 1.3 2002/05/24 21:22:37 deraadt Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1996 by Internet Software Consortium. | 4 | * Copyright (c) 1996 by Internet Software Consortium. |
@@ -19,9 +19,9 @@ | |||
19 | 19 | ||
20 | #if defined(LIBC_SCCS) && !defined(lint) | 20 | #if defined(LIBC_SCCS) && !defined(lint) |
21 | #if 0 | 21 | #if 0 |
22 | static const char rcsid[] = "$Id: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $"; | 22 | static const char rcsid[] = "$Id: inet_neta.c,v 1.3 2002/05/24 21:22:37 deraadt Exp $"; |
23 | #else | 23 | #else |
24 | static const char rcsid[] = "$OpenBSD: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $"; | 24 | static const char rcsid[] = "$OpenBSD: inet_neta.c,v 1.3 2002/05/24 21:22:37 deraadt Exp $"; |
25 | #endif | 25 | #endif |
26 | #endif | 26 | #endif |
27 | 27 | ||
@@ -73,7 +73,7 @@ inet_neta(src, dst, size) | |||
73 | if (dst == odst) { | 73 | if (dst == odst) { |
74 | if (size < sizeof "0.0.0.0") | 74 | if (size < sizeof "0.0.0.0") |
75 | goto emsgsize; | 75 | goto emsgsize; |
76 | strcpy(dst, "0.0.0.0"); | 76 | strlcpy(dst, "0.0.0.0", size); |
77 | } | 77 | } |
78 | return (odst); | 78 | return (odst); |
79 | 79 | ||
diff --git a/src/lib/libc/net/inet_ntop.c b/src/lib/libc/net/inet_ntop.c index 00b8f6b22e..212c0396b2 100644 --- a/src/lib/libc/net/inet_ntop.c +++ b/src/lib/libc/net/inet_ntop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: inet_ntop.c,v 1.2 2002/02/16 21:27:23 millert Exp $ */ | 1 | /* $OpenBSD: inet_ntop.c,v 1.3 2002/05/24 21:22:37 deraadt Exp $ */ |
2 | 2 | ||
3 | /* Copyright (c) 1996 by Internet Software Consortium. | 3 | /* Copyright (c) 1996 by Internet Software Consortium. |
4 | * | 4 | * |
@@ -20,7 +20,7 @@ | |||
20 | #if 0 | 20 | #if 0 |
21 | static char rcsid[] = "$From: inet_ntop.c,v 8.7 1996/08/05 08:41:18 vixie Exp $"; | 21 | static char rcsid[] = "$From: inet_ntop.c,v 8.7 1996/08/05 08:41:18 vixie Exp $"; |
22 | #else | 22 | #else |
23 | static char rcsid[] = "$OpenBSD: inet_ntop.c,v 1.2 2002/02/16 21:27:23 millert Exp $"; | 23 | static char rcsid[] = "$OpenBSD: inet_ntop.c,v 1.3 2002/05/24 21:22:37 deraadt Exp $"; |
24 | #endif | 24 | #endif |
25 | #endif /* LIBC_SCCS and not lint */ | 25 | #endif /* LIBC_SCCS and not lint */ |
26 | 26 | ||
@@ -89,11 +89,11 @@ inet_ntop4(src, dst, size) | |||
89 | static const char fmt[] = "%u.%u.%u.%u"; | 89 | static const char fmt[] = "%u.%u.%u.%u"; |
90 | char tmp[sizeof "255.255.255.255"]; | 90 | char tmp[sizeof "255.255.255.255"]; |
91 | 91 | ||
92 | if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) { | 92 | if (snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]) >= size) { |
93 | errno = ENOSPC; | 93 | errno = ENOSPC; |
94 | return (NULL); | 94 | return (NULL); |
95 | } | 95 | } |
96 | strcpy(dst, tmp); | 96 | strlcpy(dst, tmp, size); |
97 | return (dst); | 97 | return (dst); |
98 | } | 98 | } |
99 | 99 | ||
@@ -189,6 +189,6 @@ inet_ntop6(src, dst, size) | |||
189 | errno = ENOSPC; | 189 | errno = ENOSPC; |
190 | return (NULL); | 190 | return (NULL); |
191 | } | 191 | } |
192 | strcpy(dst, tmp); | 192 | strlcpy(dst, tmp, size); |
193 | return (dst); | 193 | return (dst); |
194 | } | 194 | } |
diff --git a/src/lib/libc/net/ipx_ntoa.c b/src/lib/libc/net/ipx_ntoa.c index 1dcfe7181b..598c94d599 100644 --- a/src/lib/libc/net/ipx_ntoa.c +++ b/src/lib/libc/net/ipx_ntoa.c | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char rcsid[] = "$OpenBSD: ipx_ntoa.c,v 1.2 1996/08/19 08:29:20 tholo Exp $"; | 35 | static char rcsid[] = "$OpenBSD: ipx_ntoa.c,v 1.3 2002/05/24 21:22:37 deraadt Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
37 | 37 | ||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> |
@@ -45,7 +45,7 @@ ipx_ntoa(addr) | |||
45 | { | 45 | { |
46 | static char obuf[] = "xxxx.xx:xx:xx:xx:xx:xx.uuuuu"; | 46 | static char obuf[] = "xxxx.xx:xx:xx:xx:xx:xx.uuuuu"; |
47 | 47 | ||
48 | sprintf(obuf, "%8xH.%02x:%02x:%02x:%02x:%02x:%02x.%u", | 48 | snprintf(obuf, sizeof obuf, "%8xH.%02x:%02x:%02x:%02x:%02x:%02x.%u", |
49 | ntohl(addr.ipx_net.l_net), | 49 | ntohl(addr.ipx_net.l_net), |
50 | addr.ipx_host.c_host[0], | 50 | addr.ipx_host.c_host[0], |
51 | addr.ipx_host.c_host[1], | 51 | addr.ipx_host.c_host[1], |
diff --git a/src/lib/libc/net/ns_ntoa.c b/src/lib/libc/net/ns_ntoa.c index 130ccd388b..3c82bc3cee 100644 --- a/src/lib/libc/net/ns_ntoa.c +++ b/src/lib/libc/net/ns_ntoa.c | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char rcsid[] = "$OpenBSD: ns_ntoa.c,v 1.8 2002/02/16 21:27:23 millert Exp $"; | 35 | static char rcsid[] = "$OpenBSD: ns_ntoa.c,v 1.9 2002/05/24 21:22:37 deraadt Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
37 | 37 | ||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> |
@@ -54,7 +54,7 @@ ns_ntoa(addr) | |||
54 | u_char *uplim = up + 6; | 54 | u_char *uplim = up + 6; |
55 | 55 | ||
56 | net.net_e = addr.x_net; | 56 | net.net_e = addr.x_net; |
57 | sprintf(obuf, "%x", ntohl(net.long_e)); | 57 | snprintf(obuf, sizeof obuf, "%x", ntohl(net.long_e)); |
58 | cp = spectHex(obuf); | 58 | cp = spectHex(obuf); |
59 | cp2 = cp + 1; | 59 | cp2 = cp + 1; |
60 | while (*up==0 && up < uplim) up++; | 60 | while (*up==0 && up < uplim) up++; |
diff --git a/src/lib/libc/net/rcmd.c b/src/lib/libc/net/rcmd.c index d6814676f4..be68c599d8 100644 --- a/src/lib/libc/net/rcmd.c +++ b/src/lib/libc/net/rcmd.c | |||
@@ -34,7 +34,7 @@ | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | #if defined(LIBC_SCCS) && !defined(lint) | 36 | #if defined(LIBC_SCCS) && !defined(lint) |
37 | static char *rcsid = "$OpenBSD: rcmd.c,v 1.42 2002/05/22 04:31:14 deraadt Exp $"; | 37 | static char *rcsid = "$OpenBSD: rcmd.c,v 1.43 2002/05/24 21:22:37 deraadt Exp $"; |
38 | #endif /* LIBC_SCCS and not lint */ | 38 | #endif /* LIBC_SCCS and not lint */ |
39 | 39 | ||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> |
@@ -407,8 +407,7 @@ again: | |||
407 | first = 0; | 407 | first = 0; |
408 | if ((pwd = getpwnam(luser)) == NULL) | 408 | if ((pwd = getpwnam(luser)) == NULL) |
409 | return (-1); | 409 | return (-1); |
410 | (void)strcpy(pbuf, pwd->pw_dir); | 410 | snprintf(pbuf, sizeof pbuf, "%s/.rhosts", pwd->pw_dir); |
411 | (void)strcat(pbuf, "/.rhosts"); | ||
412 | 411 | ||
413 | /* | 412 | /* |
414 | * Change effective uid while opening .rhosts. If root and | 413 | * Change effective uid while opening .rhosts. If root and |
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 @@ | |||
82 | static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; | 82 | static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; |
83 | static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $"; | 83 | static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $"; |
84 | #else | 84 | #else |
85 | static char rcsid[] = "$OpenBSD: res_debug.c,v 1.11 2001/06/11 10:05:59 itojun Exp $"; | 85 | static 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); |
diff --git a/src/lib/libc/net/res_query.c b/src/lib/libc/net/res_query.c index 24c07491a9..53837815c3 100644 --- a/src/lib/libc/net/res_query.c +++ b/src/lib/libc/net/res_query.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: res_query.c,v 1.17 2002/02/16 21:27:23 millert Exp $ */ | 1 | /* $OpenBSD: res_query.c,v 1.18 2002/05/24 21:22:37 deraadt Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * ++Copyright++ 1988, 1993 | 4 | * ++Copyright++ 1988, 1993 |
@@ -60,7 +60,7 @@ | |||
60 | static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; | 60 | static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; |
61 | static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $"; | 61 | static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $"; |
62 | #else | 62 | #else |
63 | static char rcsid[] = "$OpenBSD: res_query.c,v 1.17 2002/02/16 21:27:23 millert Exp $"; | 63 | static char rcsid[] = "$OpenBSD: res_query.c,v 1.18 2002/05/24 21:22:37 deraadt Exp $"; |
64 | #endif | 64 | #endif |
65 | #endif /* LIBC_SCCS and not lint */ | 65 | #endif /* LIBC_SCCS and not lint */ |
66 | 66 | ||
@@ -351,7 +351,8 @@ res_querydomain(name, domain, class, type, answer, anslen) | |||
351 | } else | 351 | } else |
352 | longname = name; | 352 | longname = name; |
353 | } else | 353 | } else |
354 | sprintf(nbuf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain); | 354 | snprintf(nbuf, sizeof nbuf, "%.*s.%.*s", |
355 | MAXDNAME, name, MAXDNAME, domain); | ||
355 | 356 | ||
356 | return (res_query(longname, class, type, answer, anslen)); | 357 | return (res_query(longname, class, type, answer, anslen)); |
357 | } | 358 | } |
diff --git a/src/lib/libc/stdlib/realpath.c b/src/lib/libc/stdlib/realpath.c index 061f1a7ef1..d01b19e0f2 100644 --- a/src/lib/libc/stdlib/realpath.c +++ b/src/lib/libc/stdlib/realpath.c | |||
@@ -35,7 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #if defined(LIBC_SCCS) && !defined(lint) | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | static char *rcsid = "$OpenBSD: realpath.c,v 1.6 2002/01/12 16:24:35 millert Exp $"; | 38 | static char *rcsid = "$OpenBSD: realpath.c,v 1.7 2002/05/24 21:22:37 deraadt Exp $"; |
39 | #endif /* LIBC_SCCS and not lint */ | 39 | #endif /* LIBC_SCCS and not lint */ |
40 | 40 | ||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> |
@@ -66,7 +66,7 @@ realpath(path, resolved) | |||
66 | 66 | ||
67 | /* Save the starting point. */ | 67 | /* Save the starting point. */ |
68 | if ((fd = open(".", O_RDONLY)) < 0) { | 68 | if ((fd = open(".", O_RDONLY)) < 0) { |
69 | (void)strcpy(resolved, "."); | 69 | (void)strlcpy(resolved, ".", MAXPATHLEN); |
70 | return (NULL); | 70 | return (NULL); |
71 | } | 71 | } |
72 | 72 | ||
@@ -125,7 +125,7 @@ loop: | |||
125 | * Save the last component name and get the full pathname of | 125 | * Save the last component name and get the full pathname of |
126 | * the current directory. | 126 | * the current directory. |
127 | */ | 127 | */ |
128 | (void)strcpy(wbuf, p); | 128 | (void)strlcpy(wbuf, p, sizeof wbuf); |
129 | if (getcwd(resolved, MAXPATHLEN) == 0) | 129 | if (getcwd(resolved, MAXPATHLEN) == 0) |
130 | goto err1; | 130 | goto err1; |
131 | 131 | ||