Skip to content
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

Buffer overflow while storing .alt file using bwa mem #232

Closed
wants to merge 1 commit into from

Conversation

zachbthomas
Copy link

When using bwa mem and an .alt file containing a line greater than 1024 bytes in length, a buffer overflow results from storing .alt file contents into a 1024 byte static buffer. The fgetc() function is used in a loop to read an .alt file byte-by-byte. Each byte is manually stored in the static buffer until a line termination character is read. Exceeding the 1024 byte line size limit will overflow the buffer. This buffer overflow can be exploited to potentially gain arbitrary code execution on the system running bwa.

The proposed commits obtain the size of the .alt file and dynamically allocate adequate memory to store the entire file. The fseeko() and ftello() functions are used to determine the size of the .alt file. The calloc() function is used to dynamically allocate and initialize memory equal to the size of the file. Because enough memory is allocated to store the entire .alt file, the buffer overflow is mitigated in the commit code.

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.

None yet

1 participant