mengyao / Complete-Striped-Smith-Waterman-Library

294 stars 112 forks source link

Fix buffer overflow in main.c #48

Closed ttasa closed 2 years ago

ttasa commented 7 years ago

Fixed size limits on the length of the (-a) weight matrix file name causing a buffer overflow.

jonn-smith commented 3 years ago

FYI, FILENAME_MAX shouldn't be used to reserve space in this way (see here).

Allocating this space dynamically based on the length of the actual filename is probably the best way to go (though setting it to something very large, like 1K will likely fix most issues).

Also, strncpy would work as opposed to writing a new copy function as long as you guarantee there is enough space in mat_name for the given filename.

mengyao commented 2 years ago

Thank you very much for pointing this problem out. I resolved it with another way.