]> git.scripts.mit.edu Git - git.git/commitdiff
real_path(): reject the empty string
authorMichael Haggerty <mhagger@alum.mit.edu>
Thu, 6 Sep 2012 22:41:01 +0000 (00:41 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Sep 2012 23:19:58 +0000 (16:19 -0700)
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
abspath.c
t/t0060-path-utils.sh

index 5d624307d5a68ced9ff07c7c19e2ac603c67def6..3e8325c7368e1cb2e7f38d7a90aafdf4b9edde0c 100644 (file)
--- a/abspath.c
+++ b/abspath.c
@@ -35,6 +35,9 @@ const char *real_path(const char *path)
        if (path == buf || path == next_buf)
                return path;
 
+       if (!*path)
+               die("The empty string is not a valid path");
+
        if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
                die ("Too long path: %.*s", 60, path);
 
index 1118056a1fd6f007fd2801ab8468c46f7fbe79ba..fab5ea28b24a26e449469ffd022f01b2221c3218 100755 (executable)
@@ -144,7 +144,7 @@ test_expect_success 'absolute path rejects the empty string' '
        test_must_fail test-path-utils absolute_path ""
 '
 
-test_expect_failure 'real path rejects the empty string' '
+test_expect_success 'real path rejects the empty string' '
        test_must_fail test-path-utils real_path ""
 '