summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--openbsd-compat/bsd-asprintf.c5
2 files changed, 5 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a790a988..c14cf03d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
- (djm) [auth.c] Fix NULL pointer dereference in fakepw(). Crash would
occur if the server did not have the privsep user and an invalid user
tried to login and both privsep and krb5 auth are disabled; ok dtucker@
+ - (djm) [bsd-asprintf.c] Better test for bad vsnprintf lengths; ok dtucker@
20061108
- (dtucker) OpenBSD CVS Sync
@@ -2616,4 +2617,4 @@
OpenServer 6 and add osr5bigcrypt support so when someone migrates
passwords between UnixWare and OpenServer they will still work. OK dtucker@
-$Id: ChangeLog,v 1.4590 2006/12/04 22:08:54 djm Exp $
+$Id: ChangeLog,v 1.4591 2006/12/05 11:58:09 djm Exp $
diff --git a/openbsd-compat/bsd-asprintf.c b/openbsd-compat/bsd-asprintf.c
index 67480139..00fa0dfd 100644
--- a/openbsd-compat/bsd-asprintf.c
+++ b/openbsd-compat/bsd-asprintf.c
@@ -39,7 +39,8 @@
#define INIT_SZ 128
-int vasprintf(char **str, const char *fmt, va_list ap)
+int
+vasprintf(char **str, const char *fmt, va_list ap)
{
int ret = -1;
va_list ap2;
@@ -53,7 +54,7 @@ int vasprintf(char **str, const char *fmt, va_list ap)
ret = vsnprintf(string, INIT_SZ, fmt, ap2);
if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */
*str = string;
- } else if (ret == INT_MAX) { /* shouldn't happen */
+ } else if (ret == INT_MAX || ret < 0) { /* Bad length */
goto fail;
} else { /* bigger than initial, realloc allowing for nul */
len = (size_t)ret + 1;