diff options
author | 2002-03-06 10:02:32 +0000 | |
---|---|---|
committer | 2002-03-06 10:02:32 +0000 | |
commit | 5d35127715f75915e9da79db09ae0636914cc6a1 (patch) | |
tree | 67edb758b8f9df7a5dc32c1d6b6b3a5bdd88d1e7 | |
parent | Unbreak MD5 and SHA1 passphrases in policy check. From (diff) | |
download | wireguard-openbsd-5d35127715f75915e9da79db09ae0636914cc6a1.tar.xz wireguard-openbsd-5d35127715f75915e9da79db09ae0636914cc6a1.zip |
Fix a couple of snprintf length bugs. Same problem <chris@stallion.oz.au>
found for policy passphrases.
-rw-r--r-- | sbin/isakmpd/key.c | 8 | ||||
-rw-r--r-- | sbin/isakmpd/x509.c | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/sbin/isakmpd/key.c b/sbin/isakmpd/key.c index fbd9c966d8d..d19d6715552 100644 --- a/sbin/isakmpd/key.c +++ b/sbin/isakmpd/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.7 2002/03/05 00:10:43 deraadt Exp $ */ +/* $OpenBSD: key.c,v 1.8 2002/03/06 10:02:32 ho Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -106,14 +106,14 @@ key_printable (int type, int private, u_int8_t *data, int datalen) return strdup ((char *)data); case ISAKMP_KEY_RSA: - s = malloc (datalen * 2); + s = malloc (datalen * 2 + 1); if (!s) { - log_error ("key_printable: malloc (%d) failed", datalen * 2); + log_error ("key_printable: malloc (%d) failed", datalen * 2 + 1); return 0; } for (i = 0; i < datalen; i++) - snprintf (s + (2 * i), 2 * (datalen - i), "%02x", data[i]); + snprintf (s + (2 * i), 2 * (datalen - i) + 1, "%02x", data[i]); return s; default: diff --git a/sbin/isakmpd/x509.c b/sbin/isakmpd/x509.c index 300b6c66d01..41a40d335b6 100644 --- a/sbin/isakmpd/x509.c +++ b/sbin/isakmpd/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.68 2002/01/23 18:44:48 ho Exp $ */ +/* $OpenBSD: x509.c,v 1.69 2002/03/06 10:02:32 ho Exp $ */ /* $EOM: x509.c,v 1.54 2001/01/16 18:42:16 ho Exp $ */ /* @@ -1332,16 +1332,16 @@ x509_printable (void *cert) if (!data) return 0; - s = malloc (datalen * 2); + s = malloc (datalen * 2 + 1); if (!s) { free (data); - log_error ("x509_printable: malloc (%d) failed", datalen * 2); + log_error ("x509_printable: malloc (%d) failed", datalen * 2 + 1); return 0; } for (i = 0; i < datalen; i++) - snprintf (s + (2 * i), 2 * (datalen - i), "%02x", data[i]); + snprintf (s + (2 * i), 2 * (datalen - i) + 1, "%02x", data[i]); free (data); return s; } |