Skip to content

Commit dfab6aa

Browse files
torvaldsgitster
authored andcommitted
Make 'prepare_temp_file()' ignore st_size for symlinks
The code was already set up to not really need it, so this just massages it a bit to remove the use entirely. Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cf219d8 commit dfab6aa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

diff.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,13 +1881,12 @@ static void prepare_temp_file(const char *name,
18811881
if (S_ISLNK(st.st_mode)) {
18821882
int ret;
18831883
char buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */
1884-
size_t sz = xsize_t(st.st_size);
1885-
if (sizeof(buf) <= st.st_size)
1886-
die("symlink too long: %s", name);
1887-
ret = readlink(name, buf, sz);
1884+
ret = readlink(name, buf, sizeof(buf));
18881885
if (ret < 0)
18891886
die("readlink(%s)", name);
1890-
prep_temp_blob(temp, buf, sz,
1887+
if (ret == sizeof(buf))
1888+
die("symlink too long: %s", name);
1889+
prep_temp_blob(temp, buf, ret,
18911890
(one->sha1_valid ?
18921891
one->sha1 : null_sha1),
18931892
(one->sha1_valid ?

0 commit comments

Comments
 (0)