Bug 1672231

Summary: Samba's ZERO_STRUCT() uses undefined C11 function memset_s()
Product: [Fedora] Fedora Reporter: Milan Crha <mcrha>
Component: sambaAssignee: Guenther Deschner <gdeschner>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: abokovoy, anoopcs, asn, cheimes, gdeschner, jarrpa, jstephen, lmohanty, lslebodn, madam, monic77, releng, sbose, ssorce
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-02-15 10:29:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1674516    

Description Milan Crha 2019-02-04 10:33:42 UTC
The mass rebuild of OpenChange [1] shows a failure of the build due to reference
to memset_s() in macros provided by samba. Part of the error message is here [3].

Am I able to do anything about it in the openchange package? Eventually, am I supposed to do anything with it at all? I mean, it feels like a regression, but I do not know whether the memset_s() had been used in those macros before. If the memset_s() requires any special defines being defined, then those should be added by samba headers. 

I tried to move ndr.h include as the first include in the openchange's ndr_mapi.c file, but it didn't help at all [2]. My idea was that maybe something includes string.h before samba has a chance to influence it, but it was not it.

[1] https://koji.fedoraproject.org/koji/taskinfo?taskID=32428399
[2] https://koji.fedoraproject.org/koji/taskinfo?taskID=32531263
[3] Part of the build log from [1]:

Compiling ndr_mapi.c with -fPIC
BUILDSTDERR: In file included from /usr/include/samba-4.0/ndr.h:29,
BUILDSTDERR:                  from /usr/include/samba-4.0/dcerpc.h:32,
BUILDSTDERR:                  from libmapi/libmapi.h:45,
BUILDSTDERR:                  from ndr_mapi.c:22:
BUILDSTDERR: ndr_mapi.c: In function 'ndr_pull_EcDoRpc':
BUILDSTDERR: /usr/include/samba-4.0/util/memory.h:54:24: warning: implicit declaration of function 'memset_s'; did you mean 'memset'? [-Wimplicit-function-declaration]
BUILDSTDERR:    54 | #define ZERO_STRUCT(x) memset_s((char *)&(x), sizeof(x), 0, sizeof(x))
BUILDSTDERR:       |                        ^~~~~~~~
BUILDSTDERR: ndr_mapi.c:924:3: note: in expansion of macro 'ZERO_STRUCT'
BUILDSTDERR:   924 |   ZERO_STRUCT(r->out);
BUILDSTDERR:       |   ^~~~~~~~~~~
.
.
.
BUILDSTDERR: /usr/bin/ld: libmapi-openchange.so.2.3: undefined reference to `memset_s'
BUILDSTDERR: collect2: error: ld returned 1 exit status
BUILDSTDERR: make: *** [Makefile:450: bin/libmapixx-test] Error 1
BUILDSTDERR: error: Bad exit status from /var/tmp/rpm-tmp.aoXFCs (%build)

Comment 1 Andreas Schneider 2019-02-06 14:47:51 UTC
Could you please open an upsteam bug too?

Comment 2 Milan Crha 2019-02-06 14:58:27 UTC
Here you are:
https://bugzilla.samba.org/show_bug.cgi?id=13778

Comment 3 Christian Heimes 2019-02-07 11:11:08 UTC
*** Bug 1673312 has been marked as a duplicate of this bug. ***

Comment 4 Andreas Schneider 2019-02-07 15:09:36 UTC
Patches at: https://gitlab.com/samba-team/samba/merge_requests/238

Comment 5 Andreas Schneider 2019-02-07 15:10:45 UTC
Inside of Samba memset_s() is available as we offer an implementation for it. However it is not available publicly.

Comment 6 Milan Crha 2019-02-12 08:36:04 UTC
*** Bug 1675576 has been marked as a duplicate of this bug. ***

Comment 7 Andreas Schneider 2019-02-15 10:28:27 UTC
*** Bug 1671507 has been marked as a duplicate of this bug. ***

Comment 8 Andreas Schneider 2019-02-15 10:29:25 UTC
This has been fixed in rawhide.

Comment 11 Milan Crha 2021-01-06 08:18:19 UTC
I do not think it's an upstream fix, there is a note at the top of the page saying:
> - added covscan,samba-4.10-macros patches from Fedora
where the important part is "from Fedora".

The fix was supposed to be in samba, and it had been done in samba, almost two years ago.

The referenced patch only replaces the macro in OpenChange with an equivalent, due to it being removed from the samba public API.

Comment 12 monic77 2021-01-09 06:36:44 UTC
(In reply to Milan Crha from comment #11)
> I do not think it's an upstream fix, there is a note at the top of the page
> saying:
> > - added covscan,samba-4.10-macros patches from Fedora
> where the important part is "from Fedora".
> 
> The fix was supposed to be in samba, and it had been done in samba, almost
> two years ago.
> 
> The referenced patch only replaces the macro in OpenChange with an
> equivalent, due to it being removed from the samba public API.

Sorry, my mistake! the patch referenced just resolve a similar building error.  --!