POSIX specifies for basename(3) and dirname(3) that they
(1) may modify the string pointed to by path, or
(2) may return a pointer to internal storage (and the returned pointer might be invalidated or the storage might be overwritten by a subsequent call).
OpenBSD has chosen implementation type (1) and this assumption has leaked into some software written on OpenBSD. By contrast, FreeBSD 12+ has chosen type (2).
OpenCVS is full of basename() and dirname() calls that assume that the argument will not be written to, which runs directly counter to what FreeBSD does. I have now cleaned up the OpenBSD usr.bin/cvs (= OpenCVS) code base:
This patch should also be applied to the FreeBSD devel/opencvs port.
Thank you Christian. However, the patch does not cleanly apply, most likely because the port is based on the code from 20151230. I guess I should just update the port to the latest snapshot* which would include your patch.
*) http://www.openbsd.org/opencvs/ still promises "to be released soon". :-) Do you guys have an ETA?
Created attachment 219005 [details]
Accommodate POSIX basename(3) that takes a non-const parameter
(In reply to Alexey Dokuchaev from comment #1)
Of course the changes to -current need to be adapted. If you filter out the hunks with the $OpenBSD$ keywords, only one hunk needs manual merging... here you go, diff attached.
OpenCVS has seen little work in recent years, it's unclear when there will be another release if ever.
You could of course just extract a snapshot from the OpenBSD CVS repository.