You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Lost error in git_config_list_dup on allocation failure #7417
The dup loop does not assign the result of git_config_list_dup_entry to error. When an allocation inside it fails, the function frees the partial list and returns 0, which reports success even though *out was never set:
The caller config_file_iterator (config_file.c:278) then passes the NULL dupped list to git_config_list_iterator_new, which dereferences it at config_list.c:255 (it->head = config_list->entries). The process gets SIGSEGV where it should get -1. The fix is error = git_config_list_dup_entry(...).
Reproduce
01.c installs a counting allocator through GIT_OPT_SET_ALLOCATOR that returns NULL for the Nth allocation, which looks exactly like a real OOM to libgit2. It opens a small multi-entry config, then runs git_config_snapshot with the Nth allocation failing, for N = 1..200. Only allocations made during the snapshot can fail, so the scan does not stop first at the unchecked git_config_list_append allocation in config parsing (see 00-config_list_append-nullderef).
gcc -g -O0 01.c -I"$LIBGIT2_INCLUDE""$LIBGIT2_LIBDIR/libgit2.a" -lz -lpthread -ldl -o 01_c
./01_c # scan
gdb -ex run -ex bt --args ./01_c <cfg><N># single index
Activity