summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-09-25 22:22:54 +1000
committerDamien Miller <djm@mindrot.org>2001-09-25 22:22:54 +1000
commitc6c209401eb041077071762533a1eae0d2764577 (patch)
tree2edd106ae1b75faec599396763a402491c7052f6
parent34cb75c7083f039c6c6f97be186be6c5f599ca97 (diff)
- (djm) Avoid bad and unportable sprintf usage in compat codeV_2_9_9_P1
-rw-r--r--ChangeLog3
-rw-r--r--openbsd-compat/inet_ntop.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 33c688ce..6db224b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
- (djm) Pull in auth-krb5.c from OpenBSD CVS. NB. it is not currently used.
- (djm) Sync $sysconfdir/moduli
- (djm) Add AC_SYS_LARGEFILE configure test
+ - (djm) Avoid bad and unportable sprintf usage in compat code
20010923
- (bal) updated ssh.c to mirror minor getopts 'extern int' formating done
@@ -6568,4 +6569,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
-$Id: ChangeLog,v 1.1559.2.1 2001/09/25 06:46:10 djm Exp $
+$Id: ChangeLog,v 1.1559.2.2 2001/09/25 12:22:54 djm Exp $
diff --git a/openbsd-compat/inet_ntop.c b/openbsd-compat/inet_ntop.c
index bf3d97ad..2b8d31f8 100644
--- a/openbsd-compat/inet_ntop.c
+++ b/openbsd-compat/inet_ntop.c
@@ -104,7 +104,8 @@ inet_ntop4(src, dst, size)
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
- if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) {
+ if (snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2],
+ src[3]) > size) {
errno = ENOSPC;
return (NULL);
}
@@ -190,7 +191,8 @@ inet_ntop6(src, dst, size)
tp += strlen(tp);
break;
}
- tp += sprintf(tp, "%x", words[i]);
+ snprintf(tp, sizeof(tmp - (tp - tmp)), "%x", words[i]);
+ tp += strlen(tp);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))