-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converted CRLF in the source files and test files to LF. also fixed o…
…ne place that does not check the pointer returned by the memory allocator.
- Loading branch information
Showing
5 changed files
with
675 additions
and
647 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,72 @@ | ||
#define DDEBUG 0 | ||
#include "ddebug.h" | ||
|
||
#include "ngx_http_set_hash.h" | ||
#include "ngx_sha1.h" | ||
#include "ngx_md5.h" | ||
|
||
|
||
#ifndef SHA_DIGEST_LENGTH | ||
#define SHA_DIGEST_LENGTH 20 | ||
#endif | ||
|
||
#ifndef MD5_DIGEST_LENGTH | ||
#define MD5_DIGEST_LENGTH 16 | ||
#endif | ||
|
||
enum { | ||
SHA_HEX_LENGTH = SHA_DIGEST_LENGTH * 2, | ||
MD5_HEX_LENGTH = MD5_DIGEST_LENGTH * 2 | ||
}; | ||
|
||
|
||
ngx_int_t | ||
ngx_http_set_misc_set_sha1(ngx_http_request_t *r, | ||
ngx_str_t *res, ngx_http_variable_value_t *v) | ||
{ | ||
u_char *p; | ||
ngx_sha1_t sha; | ||
u_char sha_buf[SHA_DIGEST_LENGTH]; | ||
|
||
p = ngx_palloc(r->pool, SHA_HEX_LENGTH); | ||
if (p == NULL) { | ||
return NGX_ERROR; | ||
} | ||
|
||
ngx_sha1_init(&sha); | ||
ngx_sha1_update(&sha, v->data, v->len); | ||
ngx_sha1_final(sha_buf, &sha); | ||
|
||
ngx_hex_dump(p, sha_buf, sizeof(sha_buf)); | ||
|
||
res->data = p; | ||
res->len = SHA_HEX_LENGTH; | ||
|
||
return NGX_OK; | ||
} | ||
|
||
|
||
ngx_int_t | ||
ngx_http_set_misc_set_md5(ngx_http_request_t *r, | ||
ngx_str_t *res, ngx_http_variable_value_t *v) | ||
{ | ||
u_char *p; | ||
ngx_md5_t md5; | ||
u_char md5_buf[MD5_DIGEST_LENGTH]; | ||
|
||
p = ngx_palloc(r->pool, MD5_HEX_LENGTH); | ||
if (p == NULL) { | ||
return NGX_ERROR; | ||
} | ||
|
||
ngx_md5_init(&md5); | ||
ngx_md5_update(&md5, v->data, v->len); | ||
ngx_md5_final(md5_buf, &md5); | ||
|
||
ngx_hex_dump(p, md5_buf, sizeof(md5_buf)); | ||
|
||
res->data = p; | ||
res->len = MD5_HEX_LENGTH; | ||
|
||
return NGX_OK; | ||
} | ||
#define DDEBUG 0 | ||
#include "ddebug.h" | ||
|
||
#include "ngx_http_set_hash.h" | ||
#include "ngx_sha1.h" | ||
#include "ngx_md5.h" | ||
|
||
|
||
#ifndef SHA_DIGEST_LENGTH | ||
#define SHA_DIGEST_LENGTH 20 | ||
#endif | ||
|
||
#ifndef MD5_DIGEST_LENGTH | ||
#define MD5_DIGEST_LENGTH 16 | ||
#endif | ||
|
||
enum { | ||
SHA_HEX_LENGTH = SHA_DIGEST_LENGTH * 2, | ||
MD5_HEX_LENGTH = MD5_DIGEST_LENGTH * 2 | ||
}; | ||
|
||
|
||
ngx_int_t | ||
ngx_http_set_misc_set_sha1(ngx_http_request_t *r, | ||
ngx_str_t *res, ngx_http_variable_value_t *v) | ||
{ | ||
u_char *p; | ||
ngx_sha1_t sha; | ||
u_char sha_buf[SHA_DIGEST_LENGTH]; | ||
|
||
p = ngx_palloc(r->pool, SHA_HEX_LENGTH); | ||
if (p == NULL) { | ||
return NGX_ERROR; | ||
} | ||
|
||
ngx_sha1_init(&sha); | ||
ngx_sha1_update(&sha, v->data, v->len); | ||
ngx_sha1_final(sha_buf, &sha); | ||
|
||
ngx_hex_dump(p, sha_buf, sizeof(sha_buf)); | ||
|
||
res->data = p; | ||
res->len = SHA_HEX_LENGTH; | ||
|
||
return NGX_OK; | ||
} | ||
|
||
|
||
ngx_int_t | ||
ngx_http_set_misc_set_md5(ngx_http_request_t *r, | ||
ngx_str_t *res, ngx_http_variable_value_t *v) | ||
{ | ||
u_char *p; | ||
ngx_md5_t md5; | ||
u_char md5_buf[MD5_DIGEST_LENGTH]; | ||
|
||
p = ngx_palloc(r->pool, MD5_HEX_LENGTH); | ||
if (p == NULL) { | ||
return NGX_ERROR; | ||
} | ||
|
||
ngx_md5_init(&md5); | ||
ngx_md5_update(&md5, v->data, v->len); | ||
ngx_md5_final(md5_buf, &md5); | ||
|
||
ngx_hex_dump(p, md5_buf, sizeof(md5_buf)); | ||
|
||
res->data = p; | ||
res->len = MD5_HEX_LENGTH; | ||
|
||
return NGX_OK; | ||
} |
Oops, something went wrong.