{"thread":{"id":"14538","subject":"[PATCH] index: be careful when handling long names","startedAt":"2008-07-20T00:51:13Z","lastAt":"2008-07-20T00:51:13Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"83983","messageId":"7vhcaljs3i.fsf@gitster.siamese.dyndns.org","threadId":"14538","inReplyTo":null,"subject":"[PATCH] index: be careful when handling long names","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-20T00:51:13Z","receivedAt":"2008-07-20T00:51:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This is a follow-up to 7fec10b (index: be careful when handling long\nnames, 2008-01-18) where we fixed handling of index entries with long\nnames.  There still remained a few remaining unsafe codepaths.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-apply.c        |    2 +-\n builtin-update-index.c |    2 +-\n read-cache.c           |    2 +-\n 3 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex e15471b..f2377fe 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -2758,7 +2758,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned\n \tce = xcalloc(1, ce_size);\n \tmemcpy(ce->name, path, namelen);\n \tce->ce_mode = create_ce_mode(mode);\n-\tce->ce_flags = namelen;\n+\tce->ce_flags = create_ce_flags(namelen, 0);\n \tif (S_ISGITLINK(mode)) {\n \t\tconst char *s = buf;\n \ndiff --git a/builtin-update-index.c b/builtin-update-index.c\nindex 38eb53c..003cb98 100644\n--- a/builtin-update-index.c\n+++ b/builtin-update-index.c\n@@ -95,7 +95,7 @@ static int add_one_path(struct cache_entry *old, const char *path, int len, stru\n \tsize = cache_entry_size(len);\n \tce = xcalloc(1, size);\n \tmemcpy(ce->name, path, len);\n-\tce->ce_flags = len;\n+\tce->ce_flags = create_ce_flags(len, 0);\n \tfill_stat_cache_info(ce, st);\n \tce->ce_mode = ce_mode_from_stat(old, st->st_mode);\n \ndiff --git a/read-cache.c b/read-cache.c\nindex 1648428..2dd8131 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -498,7 +498,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n \tsize = cache_entry_size(namelen);\n \tce = xcalloc(1, size);\n \tmemcpy(ce->name, path, namelen);\n-\tce->ce_flags = namelen;\n+\tce->ce_flags = create_ce_flags(namelen, 0);\n \tfill_stat_cache_info(ce, st);\n \n \tif (trust_executable_bit && has_symlinks)\n"}]}