commit 57377f07767deab47ddba92c41308f5ba30858d8 from: Stefan Sperling date: Thu May 23 12:50:57 2019 UTC stat .idx file to determine its size, not the .pack file commit - f363d6636651617411c1b973f63133cf224199c2 commit + 57377f07767deab47ddba92c41308f5ba30858d8 blob - 9de81b2182424bdb982baa73a69d3d61ce93ee93 blob + 6779323106d7b5ee0bbd2c4fa38b3102384c0def --- lib/pack.c +++ lib/pack.c @@ -362,6 +362,7 @@ got_packidx_open(struct got_packidx **packidx, const c { const struct got_error *err = NULL; struct got_packidx *p; + struct stat sb; *packidx = NULL; @@ -373,12 +374,13 @@ got_packidx_open(struct got_packidx **packidx, const c if (p->fd == -1) return got_error_from_errno2("open", path); - err = got_pack_get_packfile_size(&p->len, path); - if (err) { + if (fstat(p->fd, &sb) != 0) { + err = got_error_from_errno2("fstat", path); close(p->fd); free(p); return err; } + p->len = sb.st_size; if (p->len < sizeof(p->hdr)) { err = got_error(GOT_ERR_BAD_PACKIDX); close(p->fd);