RAHenriksen / NGSNGS

NGSNGS: Next generation simulator for next generation sequencing data
46 stars 4 forks source link

Fix stack overflows #43

Closed MikkelSchubert closed 7 months ago

MikkelSchubert commented 8 months ago

These commits fixes stack overflows

For Complement and ReversComplement I greatly simplified the algorithm so that it runs in place and I also removed a substantial amount of unused headers in NGSNGS_misc.*.

Overflows due to potential mismatches between fraglength and strlen(seq) are also avoided by removing the fraglength parameter and I also removed the unused ReversComplement2 function. But if this functionality is needed then it can easily be re-added while still avoiding code duplication.

ANGSD commented 8 months ago

Thanks for this, we will have a look. Looks like very relevant changes.Den 8. feb. 2024 kl. 18.48 skrev Mikkel Schubert @.***>:These commits fixes stack overflows

in Complement due to not allocating space for the null terminator in ReversComplement if strlen(seq) > LENS and in Sampling_threads due to allocating too few elements for chr_idx_array.

For Complement and ReversComplement I greatly simplified the algorithm so that it runs in place and I also removed a substantial amount of unused headers in NGSNGS_misc.*. Overflows due to potential mismatches between fraglength and strlen(seq) are also avoided by removing the fraglength parameter and I also removed the unused ReversComplement2 function. But if this functionality is needed then it can easily be re-added while still avoiding code duplication.

You can view, comment on, or merge this pull request online at:   https://github.com/RAHenriksen/NGSNGS/pull/43

Commit Summary

1c69b33 Simplify (Revers)Complement and fix stack overflows bd33237 Remove chr_idx_array to fix overflow

File Changes (4 files)

M
Briggs2.cpp
(2)

M
NGSNGS_misc.cpp
(65)

M
NGSNGS_misc.h
(8)

M
Sampling.cpp
(20)

Patch Links:

https://github.com/RAHenriksen/NGSNGS/pull/43.patch https://github.com/RAHenriksen/NGSNGS/pull/43.diff

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>