Skip to content

Commit f98716f

Browse files
committed
Conf: ensure that the default path is NUL-terminated.
`ngx_conf_merge_path_value` takes care of that when it reallocates a resolved relative path, but the reallocation is skipped if we pass an absolute path with `NGX_ACME_STATE_PREFIX`.
1 parent b445488 commit f98716f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/conf/issuer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl Issuer {
331331

332332
fn default_state_path(cf: &mut ngx_conf_t, name: &ngx_str_t) -> Result<ngx_str_t, AllocError> {
333333
let mut path = Vec::new_in(cf.pool());
334-
let reserve = "acme_".len() + name.len;
334+
let reserve = "acme_".len() + name.len + 1;
335335

336336
if let Some(p) = core::option_env!("NGX_ACME_STATE_PREFIX") {
337337
let p = p.trim_end_matches('/');
@@ -344,9 +344,10 @@ fn default_state_path(cf: &mut ngx_conf_t, name: &ngx_str_t) -> Result<ngx_str_t
344344
path.try_reserve_exact(reserve).map_err(|_| AllocError)?;
345345
path.extend(b"acme_");
346346
path.extend(name.as_bytes());
347+
path.push(b'\0');
347348

348349
let (data, len, _) = path.into_raw_parts();
349-
Ok(ngx_str_t { data, len })
350+
Ok(ngx_str_t { data, len: len - 1 })
350351
}
351352

352353
#[derive(Debug, thiserror::Error)]

0 commit comments

Comments
 (0)