Bug 250489 - devel/opencvs: unportable basename(3) usage
Summary: devel/opencvs: unportable basename(3) usage
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Alexey Dokuchaev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-20 17:44 UTC by Christian Weisgerber
Modified: 2020-10-23 15:40 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (danfe)


Attachments
Accommodate POSIX basename(3) that takes a non-const parameter (9.21 KB, patch)
2020-10-23 15:38 UTC, Christian Weisgerber
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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:

https://github.com/openbsd/src/commit/431378d1a7a36c77c1b34ffa43b6933d2ecc970a

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.