davidgiven / ack

The Amsterdam Compiler Kit
http://tack.sf.net
Other
420 stars 59 forks source link

Fix static buffer overflow in genname( ) in LLgen #223

Closed tkchia closed 3 years ago

tkchia commented 3 years ago

This should fix at least some instances of the undefined reference to `LLnc_recover' error that happens in some builds (https://github.com/davidgiven/ack/issues/218).

The bug was that genname( ) used a static namebuf buffer and did not properly check for overflow when writing into it. The result was that the non_corr variable was sometimes overwritten with a non-zero value when it should be zero, causing bogus results later.

This proposed patch makes genname( ) dynamically allocate and resize a buffer for holding a target file name.

I also take this chance to fix a typo in correct_prefix().

davidgiven commented 3 years ago

Fantastic, thanks! Shame that valgrind can't detect problems with static object overflows...