Skip to content

Fix gzopen/gzclose correctness issues - #66

Open
mulugetam wants to merge 1 commit into
mainfrom
fix/gzopen-gzclose-correctness
Open

Fix gzopen/gzclose correctness issues#66
mulugetam wants to merge 1 commit into
mainfrom
fix/gzopen-gzclose-correctness

Conversation

@mulugetam

Copy link
Copy Markdown
Contributor
  • gzopen: check for open() failure (fd < 0) and gzdopen() failure (file == NULL) before registering the file in the map. Previously a failed open would pass fd=-1 to gzdopen, store a NULL-keyed map entry, and leak the fd on gzdopen failure.

  • gzclose: use off_t instead of int for the lseek return value to avoid truncation on files larger than 2 GiB. The truncated value caused truncate() to corrupt large files.

- gzopen: check for open() failure (fd < 0) and gzdopen() failure
  (file == NULL) before registering the file in the map. Previously
  a failed open would pass fd=-1 to gzdopen, store a NULL-keyed map
  entry, and leak the fd on gzdopen failure.

- gzclose: use off_t instead of int for the lseek return value to
  avoid truncation on files larger than 2 GiB. The truncated value
  caused truncate() to corrupt large files.

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant