Deal with NULL or empty input for expand_path_tokens()
authorAsanka Herath <asanka@secure-endpoints.com>
Thu, 26 Aug 2010 20:23:42 +0000 (16:23 -0400)
committerAsanka C. Herath <asanka@secure-endpoints.com>
Tue, 14 Sep 2010 12:04:13 +0000 (08:04 -0400)
_krb5_expand_path_tokens() should return an empty string if the input
string is empty or NULL, instead of always returning a NULL for these
two cases.

lib/krb5/expand_path.c

index a65ea8c743b1614dd6c7555d8e326d4c5305dc98..70096e1c7aa9a6078132328ad740a10a568fb8fb 100644 (file)
@@ -407,6 +407,11 @@ _krb5_expand_path_tokens(krb5_context context,
     const char *path_left;
     size_t len = 0;
 
+    if (path_in == NULL || *path_in == '\0') {
+        *ppath_out = strdup("");
+        return 0;
+    }
+
     *ppath_out = NULL;
 
     for (path_left = path_in; path_left && *path_left; ) {