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: https://github.com/openbsd/src/commit/431378d1a7a36c77c1b34ffa43b6933d2ecc970a 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.
I have the following issue: $ export CVS_RSH=ssh $ export CVSROOT=anoncvs@anoncvs.NetBSD.org:/cvsroot $ opencvs co -P src cvs checkout: Updating src U src/BUILDING opencvs [checkout aborted]: cvs_ent_add: fopen: `./CVS/Entries.Log': No such file or directory It seems that the commit (431378d1a7a36c77c1b34ffa43b6933d2ecc970a) fixes the issue. I haven't yet tested the patch from comment #2. Btw. I think the first MASTER_SITE should be removed. $ host ftp.stack.nl Host ftp.stack.nl not found: 3(NXDOMAIN)