substr: fix buffer overflow with utf-8 strings
authormillert <millert@openbsd.org>
Sat, 28 Oct 2023 22:38:22 +0000 (22:38 +0000)
committermillert <millert@openbsd.org>
Sat, 28 Oct 2023 22:38:22 +0000 (22:38 +0000)
commit1ba75be16dd230788bd7e15f8304ec0b071c3ce1
tree25aab910a14788db42877f955ccca016a6a19c32
parent045a1e803f2079ca5e4684a6a55dfca24767e7de
substr: fix buffer overflow with utf-8 strings

We need to use u8_strlen(), not strlen(), to compute the length.
Otherwise, there may be an out of bounds write when writing the NUL
terminator to set the length of the substring.
https://github.com/onetrueawk/awk/pull/205
usr.bin/awk/run.c