https://bugs.openldap.org/show_bug.cgi?id=9545
Issue ID: 9545 Summary: Compile warnings in OpenLDAP 2.4 branch Product: OpenLDAP Version: 2.4.58 Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: --- Component: libraries Assignee: bugs@openldap.org Reporter: simon.pichugin@gmail.com Target Milestone: ---
There are a few compile warnings that are present in OPENLDAP_REL_ENG_2_4 libraries.
I understand that 2.4 is not in an active development state anymore but I think it's important to keep it as clean as possible as the libraries are actively used by other projects.
The warnings:
tls2.c: In function ‘ldap_int_tls_connect’: tls2.c:378:9: warning: implicit declaration of function ‘ldap_pvt_tls_check_hostname’ [-Wimplicit-function-declaration] 378 | err = ldap_pvt_tls_check_hostname( ld, ssl, host ); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ thr_posix.c: In function ‘ldap_pvt_thread_set_concurrency’: thr_posix.c:93:9: warning: implicit declaration of function ‘pthread_setconcurrency’ [-Wimplicit-function-declaration] 93 | return pthread_setconcurrency( n ); | ^~~~~~~~~~~~~~~~~~~~~~ thr_posix.c: In function ‘ldap_pvt_thread_get_concurrency’: thr_posix.c:107:9: warning: implicit declaration of function ‘pthread_getconcurrency’; did you mean ‘ldap_pvt_thread_get_concurrency’? [-Wimplicit-function-declaration] 107 | return pthread_getconcurrency(); | ^~~~~~~~~~~~~~~~~~~~~~ | ldap_pvt_thread_get_concurrency charray.c: In function ‘ldap_charray2str’: charray.c:269:3: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] 269 | strncpy( p, *v, len ); | ^~~~~~~~~~~~~~~~~~~~~ charray.c:268:9: note: length computed here 268 | len = strlen( *v ); | ^~~~~~~~~~~~
Additional information: The 'implicit declaration' warnings can be potentially harmful.
If the compiler does not see the declaration of a function _before_ it is called, it assumes the following implicit declaration instead:
int fnc_name();
... which has severe consequences:
1. Only sizeof(int) bytes are read from the return value even if the function returns a different type.
2. Count and type of the arguments passed to the functions are not checked at all because the compiler has no means to know what the callee expects as parameters.
https://bugs.openldap.org/show_bug.cgi?id=9545
Howard Chu hyc@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |WONTFIX
--- Comment #1 from Howard Chu hyc@openldap.org --- Fixed in 2.5, commit cd914149a66
https://bugs.openldap.org/show_bug.cgi?id=9545
--- Comment #2 from Howard Chu hyc@openldap.org --- (In reply to Simon Pichugin from comment #0)
There are a few compile warnings that are present in OPENLDAP_REL_ENG_2_4 libraries.
I understand that 2.4 is not in an active development state anymore but I think it's important to keep it as clean as possible as the libraries are actively used by other projects.
The warnings:
tls2.c: In function ‘ldap_int_tls_connect’: tls2.c:378:9: warning: implicit declaration of function
‘ldap_pvt_tls_check_hostname’ [-Wimplicit-function-declaration] 378 | err = ldap_pvt_tls_check_hostname( ld, ssl, host ); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ thr_posix.c: In function ‘ldap_pvt_thread_set_concurrency’: thr_posix.c:93:9: warning: implicit declaration of function ‘pthread_setconcurrency’ [-Wimplicit-function-declaration] 93 | return pthread_setconcurrency( n ); | ^~~~~~~~~~~~~~~~~~~~~~ thr_posix.c: In function ‘ldap_pvt_thread_get_concurrency’: thr_posix.c:107:9: warning: implicit declaration of function ‘pthread_getconcurrency’; did you mean ‘ldap_pvt_thread_get_concurrency’? [-Wimplicit-function-declaration] 107 | return pthread_getconcurrency(); | ^~~~~~~~~~~~~~~~~~~~~~ | ldap_pvt_thread_get_concurrency charray.c: In function ‘ldap_charray2str’: charray.c:269:3: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] 269 | strncpy( p, *v, len ); | ^~~~~~~~~~~~~~~~~~~~~ charray.c:268:9: note: length computed here 268 | len = strlen( *v ); | ^~~~~~~~~~~~
Additional information: The 'implicit declaration' warnings can be potentially harmful.
But they clearly are not, in any of these cases.
If the compiler does not see the declaration of a function _before_ it is called, it assumes the following implicit declaration instead:
int fnc_name();
... which has severe consequences:
- Only sizeof(int) bytes are read from the return value even if the
function returns a different type.
These functions return int, so this is irrelevant.
- Count and type of the arguments passed to the functions are not checked
at all because the compiler has no means to know what the callee expects as parameters.
The getconcurrency/setconcurrency functions take none or one int argument, so again this is irrelevant. Note that we have already included <pthread.h> correctly, which is where these functions are declared. If you're getting these warnings that generally means your compiler environment is incorrect.
In any case, none of these warnings indicate any bug in OpenLDAP code. The ldap_pvt_tls_check_hostname prototype has been added in 2.5 to silence the warning but code is correct regardless.
https://bugs.openldap.org/show_bug.cgi?id=9545
--- Comment #3 from Simon Pichugin simon.pichugin@gmail.com --- (In reply to Howard Chu from comment #2)
The getconcurrency/setconcurrency functions take none or one int argument, so again this is irrelevant. Note that we have already included <pthread.h> correctly, which is where these functions are declared. If you're getting these warnings that generally means your compiler environment is incorrect.
I am not sure here as I don't have the same warnings on OpenLDAP 'master' branch code build (while running on completely the same environment).
In any case, none of these warnings indicate any bug in OpenLDAP code. The ldap_pvt_tls_check_hostname prototype has been added in 2.5 to silence the warning but code is correct regardless.
I agree with you. It should not hurt any execution and my main concerns were more about 'ldap_pvt_tls_check_hostname' (and ‘strncpy’ one)
Could you please suggest what can cause the 2.4 build to report these warnings while 'master' build doesn't have them?
https://bugs.openldap.org/show_bug.cgi?id=9545
--- Comment #4 from Simon Pichugin simon.pichugin@gmail.com --- (In reply to Simon Pichugin from comment #3)
Could you please suggest what can cause the 2.4 build to report these warnings while 'master' build doesn't have them?
What I mean is that 'pthread_setconcurrency' warning is not present on OpenLDAP 'master' branch build even though the environment is the same. So it doesn't look like an environment issue. (if I haven't missed something)
https://bugs.openldap.org/show_bug.cgi?id=9545
--- Comment #5 from Howard Chu hyc@openldap.org --- (In reply to Simon Pichugin from comment #4)
(In reply to Simon Pichugin from comment #3)
Could you please suggest what can cause the 2.4 build to report these warnings while 'master' build doesn't have them?
What I mean is that 'pthread_setconcurrency' warning is not present on OpenLDAP 'master' branch build even though the environment is the same. So it doesn't look like an environment issue. (if I haven't missed something)
Looks like the patch(es) for ITS#9215. commit fd23680a447b9efe1a481dd64d9c57f3873f3108 and some preceding.
https://bugs.openldap.org/show_bug.cgi?id=9545
--- Comment #6 from Howard Chu hyc@openldap.org --- (In reply to Simon Pichugin from comment #3)
I agree with you. It should not hurt any execution and my main concerns were more about 'ldap_pvt_tls_check_hostname' (and ‘strncpy’ one)
The strncpy case is certainly stupid code, but it's not broken or unsafe.
https://bugs.openldap.org/show_bug.cgi?id=9545
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |VERIFIED