Bug 257866 - security/sssd: Fails to build: nss_sha512crypt.c:33:1: error: static declaration of 'mempcpy' follows non-static declaration
Summary: security/sssd: Fails to build: nss_sha512crypt.c:33:1: error: static declarat...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm64 Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords: needs-patch, needs-qa
Depends on:
Blocks:
 
Reported: 2021-08-15 16:54 UTC by Radoslaw Ejsmont
Modified: 2022-02-23 05:20 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (lukas.slebodnik)
koobs: merge-quarterly?


Attachments
Build log (48.54 KB, application/x-gzip)
2021-08-15 16:56 UTC, Radoslaw Ejsmont
no flags Details
Check for mempcpy (2.06 KB, patch)
2021-10-13 20:41 UTC, Mikhail Teterin
mi: maintainer-approval?
Details | Diff
Modified fix for this bug and Bug 258898 (3.20 KB, patch)
2021-10-15 10:58 UTC, Richard Frewin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Radoslaw Ejsmont 2021-08-15 16:54:40 UTC
Hello,

I encountered the following error building security/sssd on arm64:

src/util/crypto/nss/nss_sha512crypt.c:33:1: error: static declaration of 'mempcpy' follows non-static declaration
mempcpy (void *dest, const void *src, size_t n)
^
/usr/include/string.h:70:7: note: previous declaration is here
void    *mempcpy(void * __restrict, const void * __restrict, size_t);
         ^
1 error generated.

Full build log attached.

FreeBSD generic 13.0-STABLE FreeBSD 13.0-STABLE #0 stable/13-n246669-5f27244beb8: Thu Aug  5 03:46:10 UTC 2021     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC  arm64

The offending prototype seems to come from /usr/include/string.h

Renaming mempcpy to _sha512_mempcpy in nss_sha512crypt.c appears to fix the issue (build succeeds).
Comment 1 Radoslaw Ejsmont 2021-08-15 16:56:19 UTC
Created attachment 227226 [details]
Build log
Comment 2 Radoslaw Ejsmont 2021-08-15 16:58:01 UTC
>Renaming mempcpy to _sha512_mempcpy in nss_sha512crypt.c appears to fix the issue >(build succeeds).

Naturally both in the static function definition and in all uses of mempcpy within  nss_sha512crypt.c

;)
Comment 3 Mikhail Teterin freebsd_committer freebsd_triage 2021-10-13 20:41:23 UTC
Created attachment 228679 [details]
Check for mempcpy

The root cause of the problem is that FreeBSD-13.0 has mempcpy(3) in libc -- and declared in <string.h>, whereas the earlier versions did not.

There are several other ports affected -- chromium among them (Bug #257352). The earlier solutions simply grep-ed /usr/include/string.h for mempcpy.

Here I'm offering a different approach -- test for the function's using configure. It has the advantage of being (potentially) acceptable upstream.
Comment 4 Richard Frewin 2021-10-15 10:58:06 UTC
Created attachment 228718 [details]
Modified fix for this bug and Bug 258898

(In reply to Mikhail Teterin from comment #3)

For me the test in configure.ac always succeeds using poudriere on 12.2 with a 12.2 jail (even though 12.2 does not have mempcpy). I think the compile results only in a warning as it looks like -Werror is not set by default.

Attached is a patch that combines my modification of this fix with a patch from Bug 258898 for the package failure.
Comment 5 Kubilay Kocak freebsd_committer freebsd_triage 2022-02-22 23:18:53 UTC
@Richard Could you separate out the modification for this issuem, obsoleting the original attachment 228718 [details] when attaching as bug 258898 is already closed

@Mikhail Are you able to review Richards patch?
Comment 6 commit-hook freebsd_committer freebsd_triage 2022-02-23 05:05:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6cf646c7a526c6c4ca21b2faa9c10b3970f72850

commit 6cf646c7a526c6c4ca21b2faa9c10b3970f72850
Author:     Mikhail Teterin <mi@FreeBSD.org>
AuthorDate: 2022-02-23 04:59:36 +0000
Commit:     Mikhail Teterin <mi@FreeBSD.org>
CommitDate: 2022-02-23 04:59:36 +0000

    security/sssd: implement detection of mempcpy at configure-time

    Newer versions of FreeBSD provide mempcpy, which conflicts with the port's
    own implementation -- meant for the older versions.

    While here, fix compilation with newer Python -- not just 3.7 -- and relax
    the requirement for Python-version. This necessitated bumping PORTREVISION --
    because the default Python is 3.8 nowadays.

    Also, define TEST_TARGET -- and fix one of the test to compile. This needs
    further work, however.

    PR:     257866

 security/sssd/Makefile                             |  6 ++--
 security/sssd/files/patch-configure.ac             | 25 +++++++++++--
 .../files/patch-src__external__python.m4 (new)     |  9 +++++
 ...tch-src__tests__cmocka__test_negcache_2.c (new) | 42 ++++++++++++++++++++++
 ...__util__crypto__libcrypto__crypto_sha512crypt.c |  4 ++-
 ...patch-src__util__crypto__nss__nss_sha512crypt.c |  4 ++-
 6 files changed, 83 insertions(+), 7 deletions(-)
Comment 7 Mikhail Teterin freebsd_committer freebsd_triage 2022-02-23 05:20:57 UTC
Thanks, Richard, for the idea!