Mercurial > hg > nginx
comparison src/os/unix/ngx_user.c @ 3796:7dec2852e8fd
allocate last zero byte in ngx_crypt()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 29 Nov 2010 09:23:25 +0000 |
parents | 2a92804f4109 |
children | 9c057d5e1c27 |
comparison
equal
deleted
inserted
replaced
3795:254c09d0f791 | 3796:7dec2852e8fd |
---|---|
39 value = crypt_r((char *) key, (char *) salt, &cd); | 39 value = crypt_r((char *) key, (char *) salt, &cd); |
40 | 40 |
41 err = ngx_errno; | 41 err = ngx_errno; |
42 | 42 |
43 if (err == 0) { | 43 if (err == 0) { |
44 len = ngx_strlen(value); | 44 len = ngx_strlen(value) + 1; |
45 | 45 |
46 *encrypted = ngx_pnalloc(pool, len); | 46 *encrypted = ngx_pnalloc(pool, len); |
47 if (*encrypted) { | 47 if (*encrypted) { |
48 ngx_memcpy(*encrypted, value, len + 1); | 48 ngx_memcpy(*encrypted, value, len); |
49 return NGX_OK; | 49 return NGX_OK; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt_r() failed"); | 53 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt_r() failed"); |
77 ngx_set_errno(0); | 77 ngx_set_errno(0); |
78 | 78 |
79 value = crypt((char *) key, (char *) salt); | 79 value = crypt((char *) key, (char *) salt); |
80 | 80 |
81 if (value) { | 81 if (value) { |
82 len = ngx_strlen(value); | 82 len = ngx_strlen(value) + 1; |
83 | 83 |
84 *encrypted = ngx_pnalloc(pool, len); | 84 *encrypted = ngx_pnalloc(pool, len); |
85 if (*encrypted) { | 85 if (*encrypted) { |
86 ngx_memcpy(*encrypted, value, len + 1); | 86 ngx_memcpy(*encrypted, value, len); |
87 } | 87 } |
88 | 88 |
89 #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT) | 89 #if (NGX_THREADS && NGX_NONREENTRANT_CRYPT) |
90 ngx_mutex_unlock(ngx_crypt_mutex); | 90 ngx_mutex_unlock(ngx_crypt_mutex); |
91 #endif | 91 #endif |