Skip to content

Commit

Permalink
Make 'prepare_temp_file()' ignore st_size for symlinks
Browse files Browse the repository at this point in the history
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 <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Dec 17, 2008
1 parent cf219d8 commit dfab6aa
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1881,13 +1881,12 @@ static void prepare_temp_file(const char *name,
if (S_ISLNK(st.st_mode)) {
int ret;
char buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */
size_t sz = xsize_t(st.st_size);
if (sizeof(buf) <= st.st_size)
die("symlink too long: %s", name);
ret = readlink(name, buf, sz);
ret = readlink(name, buf, sizeof(buf));
if (ret < 0)
die("readlink(%s)", name);
prep_temp_blob(temp, buf, sz,
if (ret == sizeof(buf))
die("symlink too long: %s", name);
prep_temp_blob(temp, buf, ret,
(one->sha1_valid ?
one->sha1 : null_sha1),
(one->sha1_valid ?
Expand Down

0 comments on commit dfab6aa

Please sign in to comment.