Fix long standing logic bug in basename() introduced in 1.4.
authorJeroen Ruigrok/asmodai <asmodai@dragonflybsd.org>
Sun, 18 Sep 2005 13:21:13 +0000 (13:21 +0000)
committerJeroen Ruigrok/asmodai <asmodai@dragonflybsd.org>
Sun, 18 Sep 2005 13:21:13 +0000 (13:21 +0000)
commit477ab6dff488cd755752d83deee1b62bef49a06b
treeaf28db161e07b8ad2949a4d8fe7207e259a021ea
parenta15492ffc2d5051087499e54cfc6263de9eab8a3
Fix long standing logic bug in basename() introduced in 1.4.

We do not want to copy MAXPATHLEN/sizeof(bname) with strlcpy() since that will
happily copy ANY trailing slash, negating the entire pointer arithmatic of
endp and startp above.
Instead, reinstate endp - startp as size parameter to the copy function.
However, normally where a + 1 would be needed to solve the outcome, we now need
+ 2 due to strlcpy() only copying *size - 1*.
lib/libc/gen/basename.c