Attention is currently required from: Jakub Czapiga, Julius Werner.
Yu-Ping Wu has posted comments on this change by Yu-Ping Wu. ( https://review.coreboot.org/c/coreboot/+/83765?usp=email )
Change subject: lib/string: Add strncat() and strcat() functions ......................................................................
Patch Set 4:
(1 comment)
File src/lib/string.c:
https://review.coreboot.org/c/coreboot/+/83765/comment/ae9fa85d_67e9e060?usp... : PS3, Line 107: strncpy(dst + strlen(dst), src, count);
This isn't really a great implementation (walks the string twice). Better would be something like: […]
Does it walk the string twice? `strlen(dst)` walks `dst` once, and `strncpy` walks `src` once. BTW libpayload's implementation really walks `src` twice.
However I just found 2 problems in this implementation:
1. `strncpy` may not append a null byte when `count` is small. 2. Unlike `strncpy`, `dst` doesn't need to be padded with zeros (up to `count` bytes).
Therefore I decided to not use `strncpy` here. Also modified the test to catch the problem #1 above.