Bug 250489

Summary: devel/opencvs: unportable basename(3) usage
Product: Ports & Packages Reporter: Christian Weisgerber <naddy>
Component: Individual Port(s)Assignee: Alexey Dokuchaev <danfe>
Status: Open ---    
Severity: Affects Some People Flags: bugzilla: maintainer-feedback? (danfe)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Description Flags
Accommodate POSIX basename(3) that takes a non-const parameter none

Description Christian Weisgerber freebsd_committer 2020-10-20 17:44:23 UTC
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.
Comment 1 Alexey Dokuchaev freebsd_committer 2020-10-23 08:56:24 UTC
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?
Comment 2 Christian Weisgerber freebsd_committer 2020-10-23 15:38:49 UTC
Created attachment 219005 [details]
Accommodate POSIX basename(3) that takes a non-const parameter
Comment 3 Christian Weisgerber freebsd_committer 2020-10-23 15:40:52 UTC
(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.