Skip to content

Fix big-endian test failures and use-after-free issues in error handling #2408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 22, 2025

Conversation

jmarshall
Copy link
Member

The incorrect type in mpileup_get_val() in plugins/vrfs.c caused incorrect results and test failures on big-endian machines, as pos was essentially always set to 0 (being the high-order bits of the int64_t).

Accessing fileptr->errcode after closing the fileptr is invalid as generally the file structure will have been deallocated. This replaces that with strerror(errno), as is already done in vcfconvert.c. Also report the right file pointer's errcode after bgzf_write() failure.

And some other Makefile fixes and other miscellanea.

jmarshall added 4 commits May 22, 2025 21:37
On little-endian hosts, `int` here caused incorrect results at positions
beyond the range of int. On big-endian hosts, it caused incorrect results
at all positions.
Calling bgzf_close() (and hts_close()) frees the file pointer, so the
errcode field cannot be accessed afterwards. Report errors as per errno
instead as is done in vcfconvert.c.

Also report the right file pointer's errcode after bgzf_write() failure.
@pd3 pd3 merged commit 21b17b5 into samtools:develop May 22, 2025
8 checks passed
@pd3
Copy link
Member

pd3 commented May 22, 2025

Thank you

@jmarshall jmarshall deleted the bigendian+misc branch July 1, 2025 22:16
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.

2 participants