aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-12-17 10:31:36 -0800
committerJunio C Hamano <gitster@pobox.com>2008-12-17 13:36:34 -0800
commitdfab6aaecfe9df67123efc778f6aea4e9814715a (patch)
treef4ba53a0681ed08c28259ea797767628952b99ed /diff.c
parentcf219d8c68ada1aa2855f4862f15753a32d09641 (diff)
downloadgit-dfab6aaecfe9df67123efc778f6aea4e9814715a.tar.gz
git-dfab6aaecfe9df67123efc778f6aea4e9814715a.tar.xz
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 <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/diff.c b/diff.c
index 4b2029caa..f160c1a35 100644
--- a/diff.c
+++ b/diff.c
@@ -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 ?