Issue 7821 - address of strcasecmp in ldapsearch.c
Summary: address of strcasecmp in ldapsearch.c
Status: VERIFIED WORKSFORME
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: client tools (show other issues)
Version: 2.4.39
Hardware: All All
: --- normal
Target Milestone: 2.5.0
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-20 14:04 UTC by h.nardmann@secunet.de
Modified: 2020-04-19 19:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description h.nardmann@secunet.de 2014-03-20 14:04:06 UTC
Full_Name: Heiko Nardmann
Version: 2.4.39
OS: MinGW32
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (2001:a60:f08d:1:159e:f75f:8f0:44f1)


In clients/tools/ldapsearch.c the address of 'strcasecmp' is taken (inside
'dosearch()') around line 1455. That means that 'strcasecmp' is exported as an
undefined symbol into ldapsearch.o even if 'strcasecmp' is declared as
'always_inline'.

MinGW is such a platform which offers 'strcasecmp' by providing an inline
version of 'strcasecmp' (redirecting it to 'stricmp'). So this taking of an
address breaks linking.

Workaround:

before 'dosearch()' I place a local wrapper:

static int local_strcasecmp(const char *s1, const char *s2)
{
	return strcasecmp(s1, s2);
}

and inside 'dosearch' instead of

		if( sortattr ) {
			(void) ldap_sort_entries( ld, &res,
				( *sortattr == '\0' ) ? NULL : sortattr, strcasecmp );
		}

I now have

		if( sortattr ) {
			(void) ldap_sort_entries( ld, &res,
				( *sortattr == '\0' ) ? NULL : sortattr, local_strcasecmp );
		}

Some options to really solve that issue:

1) use my approach for all platforms.
2) change autoconf stuff to detect whether 'strcasecmp' is just inlined (MinGW)
or a "real" function (other platforms).

Thx in advance!

  Heiko
Comment 1 Ryan Tandy 2020-04-19 02:50:34 UTC
I'm not sure what version of MinGW this report applied to.

In the current version of MinGW32, strcasecmp exists as a stub in libmingwex.a.

https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/commits/93fc8c251370d5207558c59efbff49dcb21265fb

In the current version of MinGW-w64, strcasecmp exists as an alias in libmsvcrt.a.

https://github.com/mirror/mingw-w64/commit/3ce37840afba411f0cc836c5ff73a5f42d4eb2f0

It looks like there's no longer any need for OpenLDAP to do anything special with strcasecmp.