Bug 3152

Summary: #ifdef around memmem() is invalid.
Product: Portable OpenSSH Reporter: balu <balu.gajjala>
Component: MiscellaneousAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED WORKSFORME    
Severity: enhancement CC: bagajjal, dtucker
Priority: P5    
Version: 8.2p1   
Hardware: Other   
OS: Windows 10   

Description balu 2020-04-23 05:12:13 AEST
Different #ifdef used for memmem() declaration and definition.

https://github.com/openssh/openssh-portable/blob/d6cc76176216fe3fac16cd20d148d75cb9c50876/openbsd-compat/openbsd-compat.h#L76 

#if defined(HAVE_DECL_MEMMEM) && HAVE_DECL_MEMMEM == 0
void *memmem(const void *, size_t, const void *, size_t);
#endif

https://github.com/openssh/openssh-portable/blob/d6cc76176216fe3fac16cd20d148d75cb9c50876/openbsd-compat/memmem.c#L32 still uses #ifndef HAVE_MEMMEM.
Comment 1 Darren Tucker 2020-04-23 09:51:20 AEST
Nope that's deliberate.  HAVE_MEMMEM means you have the function, HAVE_DECL_MEMMEM means you have the function declaration.

Over in bug#3102 we found a system that had the function but not the declaration. At least I think that's what was going on.  I don't have access to the affected system but the HAVE_DECL_MEMMEM change did apparently fix it.
Comment 2 balu 2020-04-24 04:49:33 AEST
Interesting. If there is a system that doesn't have a declaration but has a definition then the issue is specific to that environment? Is it expected behavior? I guess No?
Comment 3 Darren Tucker 2020-04-24 11:04:05 AEST
(In reply to balu from comment #2)
> Interesting. If there is a system that doesn't have a declaration
> but has a definition then the issue is specific to that environment?

Like I said I think that's what was going on, but it's not 100% clear (the reporter said they did not have HAVE_MEMMEM, but in that case I would have expected the old "#ifndef HAVE_MEMMEM" to have worked).

> Is it expected behavior? I guess No?

Well I'd expect a platform to have both declaration and implementation but in the case of having implementation only I'd expect it to cause problems in LP64 platforms.

There's a lot of weirdness out there.
Comment 4 Damien Miller 2021-04-23 14:57:34 AEST
closing resolved bugs as of 8.6p1 release