Uninett / mod_auth_mellon

An Apache module with a simple SAML 2.0 service provider
207 stars 182 forks source link

missing include <strings.h> causes implicit function declaration: rindex on Solaris #207

Closed batrla closed 5 years ago

batrla commented 5 years ago

Compilation on Solaris reports warning:

"auth_mellon_diagnostics.c", line 188: warning: implicit function declaration: rindex
"auth_mellon_diagnostics.c", line 188: warning: improper pointer/integer combination: op "="

And binary dumps core (SPARCv9 64-bit), because rindex() is assumed to be integer type, so compiler sign extends its return value and then uses the number as a pointer:

mod_auth_mellon.so`am_diag_cond_str+0x154:      call   -0x1e119 <PLT=libc.so.1`rindex>
mod_auth_mellon.so`am_diag_cond_str+0x159:      movslq %eax,%rax
mod_auth_mellon.so`am_diag_cond_str+0x15c:      testq  %rax,%rax
mod_auth_mellon.so`am_diag_cond_str+0x15f:      je     +0x7     <mod_auth_mellon.so`am_diag_cond_str+0x168>
mod_auth_mellon.so`am_diag_cond_str+0x161:      movb   $0x5d,(%rax) <- SIGSEGV

Please see attached patch for suggested fix.

batrla commented 5 years ago

diff -ru mod_auth_mellon-0.14.1/auth_mellon.h mod_auth_mellon-0.14.1.new/auth_mellon.h
--- mod_auth_mellon-0.14.1/auth_mellon.h    2018-07-25 10:19:25.000000000 +0000
+++ mod_auth_mellon-0.14.1.new/auth_mellon.h    2019-03-26 20:29:06.894212725 +0000
@@ -25,6 +25,7 @@
 #include "config.h"

 #include <stdbool.h>
+#include <strings.h>

 #include <lasso/lasso.h>
 #include <lasso/xml/saml-2.0/samlp2_authn_request.h>
olavmrk commented 5 years ago

Hi,

could you please submit this as a pull request? That would make it trivial to apply.

olavmrk commented 5 years ago

Fixed by #208