X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=diff.c;h=17d68fa699f7c88aef8e6c1a0812575bfaec70e1;hb=50b4e0c178777a27164eb67676593255a9cbd035;hp=c8159183dac830bf7cba20edf480712f039d7135;hpb=47dd0d595d04ee5283dfd8a0b4cbd6e6de8ad57f;p=git.git diff --git a/diff.c b/diff.c index c8159183..17d68fa6 100644 --- a/diff.c +++ b/diff.c @@ -504,9 +504,9 @@ static void prepare_temp_file(const char *name, } if (S_ISLNK(st.st_mode)) { int ret; - char *buf, buf_[1024]; - buf = ((sizeof(buf_) < st.st_size) ? - xmalloc(st.st_size) : buf_); + char buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */ + if (sizeof(buf) <= st.st_size) + die("symlink too long: %s", name); ret = readlink(name, buf, st.st_size); if (ret < 0) die("readlink(%s)", name); @@ -650,7 +650,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one) if (DIFF_FILE_VALID(one)) { if (!one->sha1_valid) { struct stat st; - if (stat(one->path, &st) < 0) + if (lstat(one->path, &st) < 0) die("stat %s", one->path); if (index_path(one->sha1, one->path, &st, 0)) die("cannot hash %s\n", one->path); @@ -787,7 +787,7 @@ int diff_setup_done(struct diff_options *options) * so it is safe for us to do this here. Also * it does not smudge active_cache or active_nr * when it fails, so we do not have to worry about - * cleaning it up oufselves either. + * cleaning it up ourselves either. */ read_cache(); }