merge r3797:

allocate last zero byte in ngx_crypt()
This commit is contained in:
Igor Sysoev 2010-12-14 19:35:44 +00:00
parent a9166b8255
commit 1613129672

View file

@ -41,11 +41,11 @@ ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
err = ngx_errno; err = ngx_errno;
if (err == 0) { if (err == 0) {
len = ngx_strlen(value); len = ngx_strlen(value) + 1;
*encrypted = ngx_pnalloc(pool, len); *encrypted = ngx_pnalloc(pool, len);
if (*encrypted) { if (*encrypted) {
ngx_memcpy(*encrypted, value, len + 1); ngx_memcpy(*encrypted, value, len);
return NGX_OK; return NGX_OK;
} }
} }
@ -79,11 +79,11 @@ ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
value = crypt((char *) key, (char *) salt); value = crypt((char *) key, (char *) salt);
if (value) { if (value) {
len = ngx_strlen(value); len = ngx_strlen(value) + 1;
*encrypted = ngx_pnalloc(pool, len); *encrypted = ngx_pnalloc(pool, len);
if (*encrypted) { if (*encrypted) {
ngx_memcpy(*encrypted, value, len + 1); ngx_memcpy(*encrypted, value, len);
} }
#if (NGX_THREADS && NGX_NONREENTRANT_CRYPT) #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)