Skip to content

Commit 3efe5d1

Browse files
mhaggergitster
authored andcommitted
real_path(): reject the empty string
Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5c4521 commit 3efe5d1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

abspath.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const char *real_path(const char *path)
3535
if (path == buf || path == next_buf)
3636
return path;
3737

38+
if (!*path)
39+
die("The empty string is not a valid path");
40+
3841
if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
3942
die ("Too long path: %.*s", 60, path);
4043

t/t0060-path-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ test_expect_success 'absolute path rejects the empty string' '
144144
test_must_fail test-path-utils absolute_path ""
145145
'
146146

147-
test_expect_failure 'real path rejects the empty string' '
147+
test_expect_success 'real path rejects the empty string' '
148148
test_must_fail test-path-utils real_path ""
149149
'
150150

0 commit comments

Comments
 (0)