Ushering out strlcpy()
Ushering out strlcpy()
Posted Sep 2, 2022 12:08 UTC (Fri) by mathstuf (subscriber, #69389)In reply to: Ushering out strlcpy() by mtodorov
Parent article: Ushering out strlcpy()
You've broken compatibility for callers which do something like:
```
size_t ret = bufsz;
size_t sz = bufsz;
while (sz <= ret) {
ret = strlcpy(buf, in, bufsz);
if (sz <= ret) {
buf = realloc(buf, ret);
sz = ret;
}
}
```
to 1-stepping the buffer increment instead of just doing a single realloc-enough loop. The return value is "the size that would have been attempted", not "something bigger than".
