diff options
Diffstat (limited to 'openbsd-compat/inet_ntop.c')
-rw-r--r-- | openbsd-compat/inet_ntop.c | 6 |
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)) |