From cabfe32c335002d2cfc77481c33d091cc7fd0dda Mon Sep 17 00:00:00 2001 From: Heimdal Developers Date: Mon, 23 Jul 2012 17:27:56 +0100 Subject: [PATCH] Import of code from heimdal This commit updates the code imported from heimdal to b8a53329fc8bf2fe8c4f4058512f828d7654e3f8 (switch-from-svn-to-git-3003-gb8a5332) Upstream changes are: Jeffrey Altman (2): Windows: rk_strdup allocator Windows: rk_wcsdup allocator Nicolas Williams (1): Fix bug in _krb5_expand_path_tokensv() Change-Id: I08abb25b4f4136bccb3eaf8d8c44851ce748f395 Reviewed-on: http://gerrit.openafs.org/7842 Reviewed-by: Derrick Brashear Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- src/external/heimdal-last | 2 +- src/external/heimdal/krb5/expand_path.c | 22 ++++++++++++---------- src/external/heimdal/roken/roken.h.in | 8 ++++++++ src/external/heimdal/roken/win32_alloc.c | 14 ++++++++++++++ 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/external/heimdal-last b/src/external/heimdal-last index 647676d48..40aef8fab 100644 --- a/src/external/heimdal-last +++ b/src/external/heimdal-last @@ -1 +1 @@ -3fe55728404c602884f16126e9cc60fc5a3d8f20 +b8a53329fc8bf2fe8c4f4058512f828d7654e3f8 diff --git a/src/external/heimdal/krb5/expand_path.c b/src/external/heimdal/krb5/expand_path.c index 456ba305c..dd82fdb30 100644 --- a/src/external/heimdal/krb5/expand_path.c +++ b/src/external/heimdal/krb5/expand_path.c @@ -445,7 +445,8 @@ free_extra_tokens(char **extra_tokens) * * @context A krb5_context * @path_in The path to expand tokens from - * @token Variable number of pairs of strings, the first of each + * @ppath_out The expanded path + * @... Variable number of pairs of strings, the first of each * being a token (e.g., "luser") and the second a string to * replace it with. The list is terminated by a NULL. * @@ -462,7 +463,7 @@ _krb5_expand_path_tokensv(krb5_context context, char **extra_tokens = NULL; const char *path_left; const char *s; - size_t nextra_tokens = 0; + size_t nargs = 0; size_t len = 0; va_list ap; @@ -475,21 +476,22 @@ _krb5_expand_path_tokensv(krb5_context context, va_start(ap, ppath_out); while ((s = va_arg(ap, const char *))) { - nextra_tokens++; - s = va_arg(ap, const char *); + nargs++; + s = va_arg(ap, const char *); } va_end(ap); + nargs *= 2; /* Get extra tokens */ - if (nextra_tokens) { + if (nargs) { size_t i; - extra_tokens = calloc(nextra_tokens + 2, sizeof (*extra_tokens)); + extra_tokens = calloc(nargs + 1, sizeof (*extra_tokens)); if (extra_tokens == NULL) return krb5_enomem(context); va_start(ap, ppath_out); - for (i = 0; i < nextra_tokens; i++) { - s = va_arg(ap, const char *); + for (i = 0; i < nargs; i++) { + s = va_arg(ap, const char *); /* token key */ if (s == NULL) break; extra_tokens[i] = strdup(s); @@ -497,9 +499,9 @@ _krb5_expand_path_tokensv(krb5_context context, free_extra_tokens(extra_tokens); return krb5_enomem(context); } - s = va_arg(ap, const char *); + s = va_arg(ap, const char *); /* token value */ if (s == NULL) - break; + s = ""; extra_tokens[i] = strdup(s); if (extra_tokens[i] == NULL) { free_extra_tokens(extra_tokens); diff --git a/src/external/heimdal/roken/roken.h.in b/src/external/heimdal/roken/roken.h.in index 7194edf97..bf05de3d5 100644 --- a/src/external/heimdal/roken/roken.h.in +++ b/src/external/heimdal/roken/roken.h.in @@ -358,6 +358,8 @@ rk_vsnprintf (char *str, size_t sz, const char *format, va_list args); #define free rk_free #define malloc rk_malloc #define realloc rk_realloc +#define strdup rk_strdup +#define wcsdup rk_wcsdup #endif ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL @@ -372,6 +374,12 @@ rk_malloc(size_t); ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL rk_realloc(void *, size_t); +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +rk_strdup(const char *); + +ROKEN_LIB_FUNCTION unsigned short * ROKEN_LIB_CALL +rk_wcsdup(const unsigned short *); + #endif /* _MSC_VER */ #ifdef HAVE_WINSOCK diff --git a/src/external/heimdal/roken/win32_alloc.c b/src/external/heimdal/roken/win32_alloc.c index 42ebbf7be..40fe0f4fe 100644 --- a/src/external/heimdal/roken/win32_alloc.c +++ b/src/external/heimdal/roken/win32_alloc.c @@ -33,6 +33,8 @@ #undef calloc #undef malloc #undef free +#undef strdup +#undef wcsdup /* * Windows executables and dlls suffer when memory is @@ -60,3 +62,15 @@ rk_malloc(size_t size) { return malloc( size); } + +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +rk_strdup(const char *str) +{ + return strdup( str); +} + +ROKEN_LIB_FUNCTION unsigned short * ROKEN_LIB_CALL +rk_wcsdup(const unsigned short *str) +{ + return wcsdup( str); +} -- 2.39.5