diff options
author | Damien Miller <djm@mindrot.org> | 2006-12-05 22:58:09 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2006-12-05 22:58:09 +1100 |
commit | be6db83462c0d4a7067ab303644440026c93d685 (patch) | |
tree | 6d5046270034586e766ce80c35aae7cab23745a1 | |
parent | 143c2ef1ce072966d27d269d9acfed08796c390c (diff) |
- (djm) [bsd-asprintf.c] Better test for bad vsnprintf lengths; ok dtucker@
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | openbsd-compat/bsd-asprintf.c | 5 |
2 files changed, 5 insertions, 3 deletions
@@ -2,6 +2,7 @@ | |||
2 | - (djm) [auth.c] Fix NULL pointer dereference in fakepw(). Crash would | 2 | - (djm) [auth.c] Fix NULL pointer dereference in fakepw(). Crash would |
3 | occur if the server did not have the privsep user and an invalid user | 3 | occur if the server did not have the privsep user and an invalid user |
4 | tried to login and both privsep and krb5 auth are disabled; ok dtucker@ | 4 | tried to login and both privsep and krb5 auth are disabled; ok dtucker@ |
5 | - (djm) [bsd-asprintf.c] Better test for bad vsnprintf lengths; ok dtucker@ | ||
5 | 6 | ||
6 | 20061108 | 7 | 20061108 |
7 | - (dtucker) OpenBSD CVS Sync | 8 | - (dtucker) OpenBSD CVS Sync |
@@ -2616,4 +2617,4 @@ | |||
2616 | OpenServer 6 and add osr5bigcrypt support so when someone migrates | 2617 | OpenServer 6 and add osr5bigcrypt support so when someone migrates |
2617 | passwords between UnixWare and OpenServer they will still work. OK dtucker@ | 2618 | passwords between UnixWare and OpenServer they will still work. OK dtucker@ |
2618 | 2619 | ||
2619 | $Id: ChangeLog,v 1.4590 2006/12/04 22:08:54 djm Exp $ | 2620 | $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 67480139e..00fa0dfd8 100644 --- a/openbsd-compat/bsd-asprintf.c +++ b/openbsd-compat/bsd-asprintf.c | |||
@@ -39,7 +39,8 @@ | |||
39 | 39 | ||
40 | #define INIT_SZ 128 | 40 | #define INIT_SZ 128 |
41 | 41 | ||
42 | int vasprintf(char **str, const char *fmt, va_list ap) | 42 | int |
43 | vasprintf(char **str, const char *fmt, va_list ap) | ||
43 | { | 44 | { |
44 | int ret = -1; | 45 | int ret = -1; |
45 | va_list ap2; | 46 | va_list ap2; |
@@ -53,7 +54,7 @@ int vasprintf(char **str, const char *fmt, va_list ap) | |||
53 | ret = vsnprintf(string, INIT_SZ, fmt, ap2); | 54 | ret = vsnprintf(string, INIT_SZ, fmt, ap2); |
54 | if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */ | 55 | if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */ |
55 | *str = string; | 56 | *str = string; |
56 | } else if (ret == INT_MAX) { /* shouldn't happen */ | 57 | } else if (ret == INT_MAX || ret < 0) { /* Bad length */ |
57 | goto fail; | 58 | goto fail; |
58 | } else { /* bigger than initial, realloc allowing for nul */ | 59 | } else { /* bigger than initial, realloc allowing for nul */ |
59 | len = (size_t)ret + 1; | 60 | len = (size_t)ret + 1; |