commit f9bba04a89d0b706fe1b4d95cfe16b75b70097e1 from: Tracey Emery via: Thomas Adam date: Fri Jul 01 21:13:24 2022 UTC fix missed dup in open_blob per stsp@ commit - f4ae6ddb59a1edbd016ad7f0e27c2599f8966e19 commit + f9bba04a89d0b706fe1b4d95cfe16b75b70097e1 blob - ed7818983060b687f4b51c4d4c6eb36f83eaebd9 blob + be0c8b0881e38ae88054ee540fd74e866d711c4e --- lib/object.c +++ lib/object.c @@ -1350,7 +1350,7 @@ open_blob(struct got_blob_object **blob, struct got_re { const struct got_error *err = NULL; struct got_packidx *packidx = NULL; - int idx; + int idx, dfd = -1; char *path_packfile = NULL; uint8_t *outbuf; size_t size, hdrlen; @@ -1417,14 +1417,20 @@ open_blob(struct got_blob_object **blob, struct got_re if (sb.st_size != size) { err = got_error(GOT_ERR_PRIVSEP_LEN); + goto done; + } + + dfd = dup(outfd); + if (dfd == -1) { + err = got_error_from_errno("dup"); goto done; } (*blob)->f = fdopen(outfd, "rb"); if ((*blob)->f == NULL) { err = got_error_from_errno("fdopen"); - close(outfd); - outfd = -1; + close(dfd); + dfd = -1; goto done; } }