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>
Linus Torvalds committed
Dec 17, 2008 at 10:31 UTC
dfab6aaecfe9df67123efc778f6aea4e9814715a
1 file changed
+4
-5
diff.c
+4
-5
@@ -1881,13 +1881,12 @@ static void prepare_temp_file(const char *name,
1881
if (S_ISLNK(st.st_mode)) {
1882
int ret;
1883
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));
1885
if (ret < 0)
1886
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,
1890
(one->sha1_valid ?
1891
one->sha1 : null_sha1),
1892
(one->sha1_valid ?