mirror of
https://github.com/git-for-windows/git.git
synced 2026-07-01 07:01:33 -05:00
strstr() is not enough to validate the format placeholders in remote-object-info causing two errors: - Atoms recognized by expand_atom() but the remote doesn't returns 1, but data->type contains garbage causing segfault. - expand_atom() returns 0 for unknown atoms, calling strbuf_expand_bad_format() which ends in die() blocking local queries if the same format is shared. Add an allow_list with the supported atoms at the top of expand_atom(). In remote mode, unsupported atoms return 1 leaving the sb empty, honoring how for-each-ref handles known but inapplicable atoms. As extra safety, initialize data->type to OBJ_BAD and add a NULL check for type_name() so uninitialized data doesn't cause segfault. Update tests that expect previous die() behaviour to expect an empty string and add an explicit test for empty string return on unknown placeholder. Update caveat behaviour documentation. Mentored-by: Karthik Nayak <karthik.188@gmail.com> Mentored-by: Chandra Pratap <chandrapratap3519@gmail.com> Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>