- (djm) [bsd-asprintf.c] Better test for bad vsnprintf lengths; ok dtucker@

This commit is contained in:
Damien Miller 2006-12-05 22:58:09 +11:00
parent 143c2ef1ce
commit be6db83462
2 changed files with 5 additions and 3 deletions

View File

@ -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 $

View File

@ -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;