You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am reporting a stack-buffer-overflow error found via testing the implementation of void Assembly::readPDB(std::string filename, bool use_segid_instead_of_chainid, bool do_sort). The error is caused by operations performed on line 220, reading 600 chars into a 100-char buffer which is defined at line 210.
REPORT_ERROR( (std::string) "Assembly::read: File " + filename + " does not exists" );
char line[100];
bool is_sorted = true;
int old_resnum = -1;
longint mol_id = -1;
longint res_id = -1;
std::string molname, alt_molname, old_molname="";
fh.seekg(0);
// Loop over all lines
while (fh.getline (line, 600))
{
Testing with a valid PDB file, such as this: pdb1hho.txt does not cause the problem as each line in this specific file is 80 chars maximum. But if we add a single line (anywhere in the input PDB file) that is more than 99 characters we get a stack-buffer-overflow.
For example: this file: pdb1hho_invalid.txt results in a stack-buffer-overflow because of the way data is read into char line[100]; currently.
changing line 220: while (fh.getline (line, 600)) to while (fh.getline (line, 100)) should fix the issue without changing the expected behavior of the function.
Please let me know if I am mistaken or if you have any questions :)
Sincerely,
Arpan Srivastava
The text was updated successfully, but these errors were encountered:
changing line 220: while (fh.getline (line, 600)) to while (fh.getline (line, 100)) should fix the issue without changing the expected behavior of the function.
Yes, I agree. Please send a pull request to the ver4.0 branch, which I will propagate to ver5.0 as well.
The PDB specification says one line of a valid PDB file is up to 80 characters. So 100 should be more than enough.
Hi, I am reporting a
stack-buffer-overflow
error found via testing the implementation ofvoid Assembly::readPDB(std::string filename, bool use_segid_instead_of_chainid, bool do_sort)
. The error is caused by operations performed on line 220, reading 600 chars into a 100-char buffer which is defined at line 210.relion/src/assembly.cpp
Lines 199 to 221 in f2e59d6
Testing with a valid PDB file, such as this: pdb1hho.txt does not cause the problem as each line in this specific file is 80 chars maximum. But if we add a single line (anywhere in the input PDB file) that is more than 99 characters we get a
stack-buffer-overflow
.For example: this file: pdb1hho_invalid.txt results in a
stack-buffer-overflow
because of the way data is read intochar line[100];
currently.Example to reproduce:
Crash report:
Proposed solution:
changing line 220:
while (fh.getline (line, 600))
towhile (fh.getline (line, 100))
should fix the issue without changing the expected behavior of the function.Please let me know if I am mistaken or if you have any questions :)
Sincerely,
Arpan Srivastava
The text was updated successfully, but these errors were encountered: