X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-update-index.c;h=560497750586ec61be4e34de6dedd9c307129817;hb=8b75d31c945c9361331db8cd554f25a8ea6abc4a;hp=9d19c51e8e68d5d4c92465699c58ef0acec70209;hpb=718258e256b74622aa55f5ee0cb9cff4cce6bf9f;p=git.git diff --git a/builtin-update-index.c b/builtin-update-index.c index 9d19c51e8..560497750 100644 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@ -194,6 +194,10 @@ static int process_path(const char *path) int len; struct stat st; + len = strlen(path); + if (has_symlink_leading_path(len, path)) + return error("'%s' is beyond a symbolic link", path); + /* * First things first: get the stat information, to decide * what to do about the pathname! @@ -201,7 +205,6 @@ static int process_path(const char *path) if (lstat(path, &st) < 0) return process_lstat_error(path, errno); - len = strlen(path); if (S_ISDIR(st.st_mode)) return process_directory(path, len, &st); @@ -215,7 +218,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1, struct cache_entry *ce; if (!verify_path(path)) - return -1; + return error("Invalid path '%s'", path); len = strlen(path); size = cache_entry_size(len); @@ -294,11 +297,9 @@ static void update_one(const char *path, const char *prefix, int prefix_length) static void read_index_info(int line_termination) { - struct strbuf buf; - struct strbuf uq; + struct strbuf buf = STRBUF_INIT; + struct strbuf uq = STRBUF_INIT; - strbuf_init(&buf, 0); - strbuf_init(&uq, 0); while (strbuf_getline(&buf, stdin, line_termination) != EOF) { char *ptr, *tab; char *path_name; @@ -485,7 +486,7 @@ static int unresolve_one(const char *path) static void read_head_pointers(void) { if (read_ref("HEAD", head_sha1)) - die("No HEAD -- no initial commit yet?\n"); + die("No HEAD -- no initial commit yet?"); if (read_ref("MERGE_HEAD", merge_head_sha1)) { fprintf(stderr, "Not in the middle of a merge.\n"); exit(0); @@ -714,10 +715,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) free((char*)p); } if (read_from_stdin) { - struct strbuf buf, nbuf; + struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT; - strbuf_init(&buf, 0); - strbuf_init(&nbuf, 0); setup_work_tree(); while (strbuf_getline(&buf, stdin, line_termination) != EOF) { const char *p;