commit 0b1c1d9c3d925795955ba06a2ea73228e1c1d112 from: Lucas via: Thomas Adam date: Thu Jul 21 23:24:12 2022 UTC got_repo_pack_fds_close: don't close(0) got_repo_pack_fds_close will try to close all of the GOT_PACK_NUM_TEMPFILES fds, even the ones that didn't manage to get a value from got_opentempfd(), which would result in a close(0) if we do not initialize to -1 here. commit - 46cd746291ccc886182febe93e8bec284bebf7c5 commit + 0b1c1d9c3d925795955ba06a2ea73228e1c1d112 blob - d304ccb5060255fda421740524533ded15185934 blob + b568413a0b3be4523b319571a011282654db4476 --- lib/repository.c +++ lib/repository.c @@ -257,6 +257,14 @@ got_repo_pack_fds_open(int **pack_fds) free(pack_fds_tmp); return got_error_from_errno("calloc"); } + + /* + * got_repo_pack_fds_close will try to close all of the + * GOT_PACK_NUM_TEMPFILES fds, even the ones that didn't manage to get + * a value from got_opentempfd(), resulting in a close(0). + */ + for (i = 0; i < GOT_PACK_NUM_TEMPFILES; i++) + pack_fds_tmp[i] = -1; for (i = 0; i < GOT_PACK_NUM_TEMPFILES; i++) { pack_fds_tmp[i] = got_opentempfd();