summaryrefslogtreecommitdiff
path: root/openbsd-compat/inet_ntop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-09-25 22:21:52 +1000
committerDamien Miller <djm@mindrot.org>2001-09-25 22:21:52 +1000
commit5f4b10088fdb88ad4326211ebe9933b92d4f7eb7 (patch)
treed3a3c3b83ca95530a1445ad850a5c8fdd4b9ae51 /openbsd-compat/inet_ntop.c
parente8bb450af9bb67f9b8b2c7a1fc5659935a286788 (diff)
- (djm) Avoid bad and unportable sprintf usage in compat code
Diffstat (limited to 'openbsd-compat/inet_ntop.c')
-rw-r--r--openbsd-compat/inet_ntop.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/openbsd-compat/inet_ntop.c b/openbsd-compat/inet_ntop.c
index bf3d97ade..2b8d31f8d 100644
--- a/openbsd-compat/inet_ntop.c
+++ b/openbsd-compat/inet_ntop.c
@@ -104,7 +104,8 @@ inet_ntop4(src, dst, size)
104 static const char fmt[] = "%u.%u.%u.%u"; 104 static const char fmt[] = "%u.%u.%u.%u";
105 char tmp[sizeof "255.255.255.255"]; 105 char tmp[sizeof "255.255.255.255"];
106 106
107 if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) { 107 if (snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2],
108 src[3]) > size) {
108 errno = ENOSPC; 109 errno = ENOSPC;
109 return (NULL); 110 return (NULL);
110 } 111 }
@@ -190,7 +191,8 @@ inet_ntop6(src, dst, size)
190 tp += strlen(tp); 191 tp += strlen(tp);
191 break; 192 break;
192 } 193 }
193 tp += sprintf(tp, "%x", words[i]); 194 snprintf(tp, sizeof(tmp - (tp - tmp)), "%x", words[i]);
195 tp += strlen(tp);
194 } 196 }
195 /* Was it a trailing run of 0x00's? */ 197 /* Was it a trailing run of 0x00's? */
196 if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) 198 if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))