Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regions array buffer overflow in egs++ viewer
After compiling egs_view with asan support, there was a buffer overflow error traced back to the memcpy call in ImageWindow::paintEvent. ERROR: AddressSanitizer: dynamic-stack-buffer-overflow ... READ of size 400 at 0x7ffe71889e40 thread T0 #0 0x7f543595ecdf (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x99cdf) nrc-cnrc#1 0x55dc3acdbb15 in memcpy nrc-cnrc#2 0x55dc3acdbb15 in ImageWindow::paintEvent(QPaintEvent*) nrc-cnrc#3 0x7f5434f86047 in QWidget::event(QEvent*) The issue is that memcpy will always copy sizeof(lastRegions) bytes into the array regions. But before this change, regions could be shorter than lastRegions, leading to a buffer overflow. After this change, maxreg is always set to N_REG_MAX, the length of lastRegions.
- Loading branch information