From 51562a71ce949804fc87289d54b3e2afc15e8001 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 29 Sep 2011 14:39:25 -0300 Subject: [PATCH 1/2] %lld was for long long int was causing segmentation faults when using cookie based authentication. Changed it to %ld , to store time, as it was 64 bit based. --- src/mod_auth_remote.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod_auth_remote.c b/src/mod_auth_remote.c index 092752b..4419cec 100644 --- a/src/mod_auth_remote.c +++ b/src/mod_auth_remote.c @@ -128,7 +128,7 @@ static char *auth_remote_signature(apr_pool_t *p, const char *user, apr_int64_t int blen = apr_base64_encode_len(APR_MD5_DIGESTSIZE); unsigned char md5[APR_MD5_DIGESTSIZE]; char *md5_b64 = apr_palloc(p, blen); - char *s = apr_psprintf(p, "%s:%lld:%s", user, curr, salt); + char *s = apr_psprintf(p, "%s:%ld:%s", user, curr, salt); apr_md5(md5, s, strlen(s)); apr_base64_encode_binary(md5_b64, md5, APR_MD5_DIGESTSIZE); @@ -188,7 +188,7 @@ static short auth_remote_validate_cookie(request_rec *r, const char *exp_user, c static void auth_remote_set_cookie(request_rec *r, const char *user, auth_remote_config_rec *conf) { apr_time_t now = apr_time_sec(apr_time_now()); - char *cookie = apr_psprintf(r->pool, "%s=%s^%lld^%s;path=%s", conf->cookie_name, user, now, + char *cookie = apr_psprintf(r->pool, "%s=%s^%ld^%s;path=%s", conf->cookie_name, user, now, auth_remote_signature(r->pool, user, now, auth_remote_salt), conf->cookie_path); apr_table_addn(r->err_headers_out, "Set-Cookie", cookie); From f48b9ba53c36841f295b8ff21427dda73ba9d8eb Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 30 Sep 2011 09:50:03 -0300 Subject: [PATCH 2/2] Earlier commit changed it to %lld to %ld for printing time. After browsing apache doc, apache has a predefined type to handle different time structures on different systems, changing to "APR_TIME_T_FMT" instead of %ld, testing and working so far. --- src/mod_auth_remote.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod_auth_remote.c b/src/mod_auth_remote.c index 4419cec..982c9e5 100644 --- a/src/mod_auth_remote.c +++ b/src/mod_auth_remote.c @@ -128,7 +128,7 @@ static char *auth_remote_signature(apr_pool_t *p, const char *user, apr_int64_t int blen = apr_base64_encode_len(APR_MD5_DIGESTSIZE); unsigned char md5[APR_MD5_DIGESTSIZE]; char *md5_b64 = apr_palloc(p, blen); - char *s = apr_psprintf(p, "%s:%ld:%s", user, curr, salt); + char *s = apr_psprintf(p, "%s:%" APR_TIME_T_FMT ":%s", user, curr, salt); apr_md5(md5, s, strlen(s)); apr_base64_encode_binary(md5_b64, md5, APR_MD5_DIGESTSIZE); @@ -188,7 +188,7 @@ static short auth_remote_validate_cookie(request_rec *r, const char *exp_user, c static void auth_remote_set_cookie(request_rec *r, const char *user, auth_remote_config_rec *conf) { apr_time_t now = apr_time_sec(apr_time_now()); - char *cookie = apr_psprintf(r->pool, "%s=%s^%ld^%s;path=%s", conf->cookie_name, user, now, + char *cookie = apr_psprintf(r->pool, "%s=%s^%" APR_TIME_T_FMT "^%s;path=%s", conf->cookie_name, user, now, auth_remote_signature(r->pool, user, now, auth_remote_salt), conf->cookie_path); apr_table_addn(r->err_headers_out, "Set-Cookie", cookie);