]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Import of code from heimdal
authorHeimdal Developers <heimdal-discuss@sics.se>
Mon, 23 Jul 2012 16:27:56 +0000 (17:27 +0100)
committerJeffrey Altman <jaltman@your-file-system.com>
Mon, 23 Jul 2012 21:48:01 +0000 (14:48 -0700)
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 <shadow@dementix.org>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
src/external/heimdal-last
src/external/heimdal/krb5/expand_path.c
src/external/heimdal/roken/roken.h.in
src/external/heimdal/roken/win32_alloc.c

index 647676d488bb8d593a895da4177481841cb4c1a8..40aef8fab0a4cde20c1b1f0a1ea23518894faf51 100644 (file)
@@ -1 +1 @@
-3fe55728404c602884f16126e9cc60fc5a3d8f20
+b8a53329fc8bf2fe8c4f4058512f828d7654e3f8
index 456ba305c3df550dab86578467d09a85249c8584..dd82fdb308c12e300e94dd63ab308a5ca4dd9f45 100644 (file)
@@ -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);
index 7194edf97c3f529cef13a9e892ce8ee02ad9317f..bf05de3d52e052bada7895e604e01751f759f5c0 100644 (file)
@@ -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
index 42ebbf7be0e204b60e895e7b381e4579dbbb0515..40fe0f4fed130c7eee62de6d95fe738eeaf9f89e 100644 (file)
@@ -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);
+}