Skip to content

Commit

Permalink
real_path(): reject the empty string
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Sep 6, 2012
1 parent a5c4521 commit 3efe5d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions abspath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion t/t0060-path-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
'

Expand Down

0 comments on commit 3efe5d1

Please sign in to comment.