commit 0c41134356d52f1dd4db38637202364533f43866 from: Lucas via: Stefan Sperling date: Thu Jul 21 20:35:52 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 - c46eda88bcbbcf577ca7a805746b44d63c0e4c0a commit + 0c41134356d52f1dd4db38637202364533f43866 blob - 1afcaaffa734eb472002229d279079cb970029da blob + 5bee3eeb0b3d98dbaddb96e055a137ca1e27012c --- lib/repository.c +++ lib/repository.c @@ -262,6 +262,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();