allocate last zero byte in ngx_crypt()

This commit is contained in:
Igor Sysoev 2010-11-29 09:23:25 +00:00
parent d64bd4e211
commit af62198836

View file

@ -41,11 +41,11 @@ ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
err = ngx_errno;
if (err == 0) {
len = ngx_strlen(value);
len = ngx_strlen(value) + 1;
*encrypted = ngx_pnalloc(pool, len);
if (*encrypted) {
ngx_memcpy(*encrypted, value, len + 1);
ngx_memcpy(*encrypted, value, len);
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);
if (value) {
len = ngx_strlen(value);
len = ngx_strlen(value) + 1;
*encrypted = ngx_pnalloc(pool, len);
if (*encrypted) {
ngx_memcpy(*encrypted, value, len + 1);
ngx_memcpy(*encrypted, value, len);
}
#if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)