nimble-code / Cobra

An interactive (fast) static source code analyzer
139 stars 31 forks source link

fix: Fixed segmentation fault in the parsing of arguments #66

Closed NickyBoy89 closed 9 months ago

NickyBoy89 commented 9 months ago

Some arguments passed to the cobra binary need multiple arguments, but do not check argc to make sure that another argument exists, resulting in an out-of-bounds read that results in a segmentation fault.

An example of behavior is in the command cobra -view -re, which segfaults as soon as it hits this line: https://github.com/nimble-code/Cobra/blob/19f463c11aad0bc72d8c72423185108dc92ffee0/src/cobra_prep.c#L1534

This PR introduces a macro that expands to set the next argument correctly, or exit with an error. Since this issue shows up in the parsing for multiple arguments, I thought that a macro was the best way to address this, but another solution may yet be better.

nimble-code commented 9 months ago

good point -- yes, there's some checking needed -- i'll update soon

nimble-code commented 9 months ago

updated to address this issue, together with a couple of unrelated fixes and extensions