CVSROOT: /cvs Module name: src Changes by: mill...@cvs.openbsd.org 2023/11/15 11:48:13
Modified files: usr.bin/awk : b.c Log message: fnematch: fix out-of-bounds access on EOF fnematch() expects to store a NUL byte when EOF is encountered. However, the rewrite broke this assumption because r.len from getrune() is zero on EOF. This results in j becoming negative on EOF, causing an out-of-bounds access. It is simplest to just force r.len to 1 on EOF to copy a single NUL byte--the rune is initialized to zero even for EOF. This also fixes the call to adjbuf(). We cannot use 'k' to determine when we need to expand the buffer now that we are potentially reading more than a single byte at a time. https://github.com/onetrueawk/awk/pull/211