diff options
author | Colin Watson <cjwatson@debian.org> | 2009-12-29 21:38:40 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2009-12-29 21:38:40 +0000 |
commit | 1b816ea846aca3ee89e7995373ace609e9518424 (patch) | |
tree | b41cdc8495cae7fa9c2e0f98a5f2e71656b61f9a /openbsd-compat/bsd-asprintf.c | |
parent | fa585019a79ebcb4e0202b1c33f87ff1c5c9ce1c (diff) | |
parent | 086ea76990b1e6287c24b6db74adffd4605eb3b0 (diff) |
import openssh-4.6p1-gsskex-20070312.patch
Diffstat (limited to 'openbsd-compat/bsd-asprintf.c')
-rw-r--r-- | openbsd-compat/bsd-asprintf.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/openbsd-compat/bsd-asprintf.c b/openbsd-compat/bsd-asprintf.c index 5ca01f80f..00fa0dfd8 100644 --- a/openbsd-compat/bsd-asprintf.c +++ b/openbsd-compat/bsd-asprintf.c | |||
@@ -21,6 +21,10 @@ | |||
21 | 21 | ||
22 | #ifndef HAVE_VASPRINTF | 22 | #ifndef HAVE_VASPRINTF |
23 | 23 | ||
24 | #include <errno.h> | ||
25 | #include <stdarg.h> | ||
26 | #include <stdlib.h> | ||
27 | |||
24 | #ifndef VA_COPY | 28 | #ifndef VA_COPY |
25 | # ifdef HAVE_VA_COPY | 29 | # ifdef HAVE_VA_COPY |
26 | # define VA_COPY(dest, src) va_copy(dest, src) | 30 | # define VA_COPY(dest, src) va_copy(dest, src) |
@@ -35,7 +39,8 @@ | |||
35 | 39 | ||
36 | #define INIT_SZ 128 | 40 | #define INIT_SZ 128 |
37 | 41 | ||
38 | int vasprintf(char **str, const char *fmt, va_list ap) | 42 | int |
43 | vasprintf(char **str, const char *fmt, va_list ap) | ||
39 | { | 44 | { |
40 | int ret = -1; | 45 | int ret = -1; |
41 | va_list ap2; | 46 | va_list ap2; |
@@ -49,7 +54,7 @@ int vasprintf(char **str, const char *fmt, va_list ap) | |||
49 | ret = vsnprintf(string, INIT_SZ, fmt, ap2); | 54 | ret = vsnprintf(string, INIT_SZ, fmt, ap2); |
50 | if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */ | 55 | if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */ |
51 | *str = string; | 56 | *str = string; |
52 | } else if (ret == INT_MAX) { /* shouldn't happen */ | 57 | } else if (ret == INT_MAX || ret < 0) { /* Bad length */ |
53 | goto fail; | 58 | goto fail; |
54 | } else { /* bigger than initial, realloc allowing for nul */ | 59 | } else { /* bigger than initial, realloc allowing for nul */ |
55 | len = (size_t)ret + 1; | 60 | len = (size_t)ret + 1; |