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: 2024-11-16 18:51 UTC (History)
1 user (show)

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 freebsd_triage 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 freebsd_triage 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 freebsd_triage 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 freebsd_triage 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.
Comment 4 Herbert J. Skuhra 2024-11-16 18:51:53 UTC
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)