Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Patch file for nginx 1.2.4 on FreeBSD ports
--- ../samizdatco-nginx-http-auth-digest-bd1c86a/ngx_http_auth_digest_module.c.orig 2011-12-29 09:00:32.000000000 +0900
+++ ../samizdatco-nginx-http-auth-digest-bd1c86a/ngx_http_auth_digest_module.c 2012-10-17 16:47:17.000000000 +0900
@@ -401,13 +401,13 @@
http_method.len = r->method_name.len+1;
http_method.data = ngx_pcalloc(r->pool, http_method.len);
if (http_method.data==NULL) return NGX_HTTP_INTERNAL_SERVER_ERROR;
- p = ngx_cpymem(http_method.data, r->method_name.data, r->method_end - r->method_name.data+1);
+ p = ngx_cpymem(http_method.data, r->method_name.data, r->method_name.len);
- ha2_key.len = http_method.len + r->uri.len + 1;
+ ha2_key.len = http_method.len + r->unparsed_uri.len + 1;
ha2_key.data = ngx_pcalloc(r->pool, ha2_key.len);
if (ha2_key.data==NULL) return NGX_HTTP_INTERNAL_SERVER_ERROR;
p = ngx_cpymem(ha2_key.data, http_method.data, http_method.len-1); *p++ = ':';
- p = ngx_cpymem(p, r->uri.data, r->uri.len);
+ p = ngx_cpymem(p, r->unparsed_uri.data, r->unparsed_uri.len);
HA2.len = 33;
HA2.data = ngx_pcalloc(r->pool, HA2.len);
@@ -417,7 +417,7 @@
ngx_hex_dump(HA2.data, hash, 16);
// calculate digest: md5(ha1:nonce:nc:cnonce:qop:ha2)
- digest_key.len = HA1.len-1 + fields->nonce.len-1 + fields->nc.len-1 + fields->cnonce.len-1 + fields->qop.len-1 + HA2.len-1 + 5 + 1;
+ digest_key.len = HA1.len + fields->nonce.len + fields->nc.len + fields->cnonce.len + fields->qop.len + HA2.len;
digest_key.data = ngx_pcalloc(r->pool, digest_key.len);
if (digest_key.data==NULL) return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -487,11 +487,11 @@
// recalculate the digest with a modified HA2 value (for rspauth) and emit the
// Authentication-Info header
ngx_memset(ha2_key.data, 0, ha2_key.len);
- p = ngx_sprintf(ha2_key.data, ":%s", r->uri.data);
+ p = ngx_snprintf(ha2_key.data, 1 + r->unparsed_uri.len, ":%s", r->unparsed_uri.data);
ngx_memset(HA2.data, 0, HA2.len);
ngx_md5_init(&md5);
- ngx_md5_update(&md5, ha2_key.data, r->uri.len);
+ ngx_md5_update(&md5, ha2_key.data, 1 + r->unparsed_uri.len);
ngx_md5_final(hash, &md5);
ngx_hex_dump(HA2.data, hash, 16);
@@ -771,8 +771,11 @@
void ngx_http_auth_digest_cleanup(ngx_event_t *ev){
if (ev->timer_set) ngx_del_timer(ev);
- ngx_add_timer(ev, NGX_HTTP_AUTH_DIGEST_CLEANUP_INTERVAL);
-
+
+ if( !(ngx_quit || ngx_terminate || ngx_exiting ) ) {
+ ngx_add_timer(ev, NGX_HTTP_AUTH_DIGEST_CLEANUP_INTERVAL);
+ }
+
if (ngx_trylock(ngx_http_auth_digest_cleanup_lock)){
ngx_http_auth_digest_rbtree_prune(ev->log);
ngx_unlock(ngx_http_auth_digest_cleanup_lock);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment