diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-05-13 10:19:46 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-05-13 10:19:46 -0700 |
| commit | 71bd0c8a616c41d03ef0658c9419c1bac862685d (patch) | |
| tree | 2ac4982bb9e83fa6ea2ec6a63fe957fbb842786e /attr.c | |
| parent | Merge branch 'jc/test-workaround-broken-mv' (diff) | |
| parent | attr.c: move ATTR_MAX_FILE_SIZE check into read_attr_from_buf() (diff) | |
| download | git-71bd0c8a616c41d03ef0658c9419c1bac862685d.tar.gz git-71bd0c8a616c41d03ef0658c9419c1bac862685d.zip | |
Merge branch 'tb/attr-limits'
The maximum size of attribute files is enforced more consistently.
* tb/attr-limits:
attr.c: move ATTR_MAX_FILE_SIZE check into read_attr_from_buf()
Diffstat (limited to 'attr.c')
| -rw-r--r-- | attr.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -765,8 +765,8 @@ static struct attr_stack *read_attr_from_file(const char *path, unsigned flags) return res; } -static struct attr_stack *read_attr_from_buf(char *buf, const char *path, - unsigned flags) +static struct attr_stack *read_attr_from_buf(char *buf, size_t length, + const char *path, unsigned flags) { struct attr_stack *res; char *sp; @@ -774,6 +774,11 @@ static struct attr_stack *read_attr_from_buf(char *buf, const char *path, if (!buf) return NULL; + if (length >= ATTR_MAX_FILE_SIZE) { + warning(_("ignoring overly large gitattributes blob '%s'"), path); + free(buf); + return NULL; + } CALLOC_ARRAY(res, 1); for (sp = buf; *sp;) { @@ -813,7 +818,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate, return NULL; } - return read_attr_from_buf(buf, path, flags); + return read_attr_from_buf(buf, sz, path, flags); } static struct attr_stack *read_attr_from_index(struct index_state *istate, @@ -860,13 +865,7 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate, stack = read_attr_from_blob(istate, &istate->cache[sparse_dir_pos]->oid, relative_path, flags); } else { buf = read_blob_data_from_index(istate, path, &size); - if (!buf) - return NULL; - if (size >= ATTR_MAX_FILE_SIZE) { - warning(_("ignoring overly large gitattributes blob '%s'"), path); - return NULL; - } - stack = read_attr_from_buf(buf, path, flags); + stack = read_attr_from_buf(buf, size, path, flags); } return stack; } |
