Skip to content

Commit 437fc46

Browse files
fixed asserting lenght of INI (#3508)
1 parent 17189c6 commit 437fc46

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

profiling/src/config.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use crate::bindings::{
44
datadog_php_profiling_copy_string_view_into_zval, ddog_php_prof_get_memoized_config,
55
zai_config_entry, zai_config_get_value, zai_config_minit, zai_config_name,
66
zai_config_system_ini_change, zend_ini_entry, zend_long, zend_string, zend_write, zval,
7-
StringError, ZaiStr, IS_FALSE, IS_LONG, IS_TRUE, ZAI_CONFIG_ENTRIES_COUNT_MAX,
8-
ZEND_INI_DISPLAY_ORIG,
7+
StringError, ZaiStr, IS_FALSE, IS_LONG, IS_TRUE, ZAI_CONFIG_NAME_BUFSIZ, ZEND_INI_DISPLAY_ORIG,
98
};
109
use crate::zend::zai_str_from_zstr;
1110
use core::fmt::{Display, Formatter};
@@ -287,7 +286,7 @@ unsafe extern "C" fn env_to_ini_name(env_name: ZaiStr, ini_name: *mut zai_config
287286
// Env var name needs to fit.
288287
let projection = "datadog.".len() - "DD_".len();
289288
let null_byte = 1usize;
290-
assert!(name.len() + projection + null_byte < ZAI_CONFIG_ENTRIES_COUNT_MAX as usize);
289+
assert!(name.len() + projection + null_byte <= (ZAI_CONFIG_NAME_BUFSIZ as usize));
291290

292291
let (dest_prefix, src_prefix) = if name.starts_with("DD_TRACE_") {
293292
("datadog.trace.", "DD_TRACE_")
@@ -1276,6 +1275,10 @@ mod tests {
12761275
b"DD_PROFILING_ALLOCATION_ENABLED\0",
12771276
"datadog.profiling.allocation_enabled",
12781277
),
1278+
(
1279+
b"DD_PROFILING_EXPERIMENTAL_EXCEPTION_SAMPLING_DISTANCE\0",
1280+
"datadog.profiling.experimental_exception_sampling_distance",
1281+
),
12791282
(
12801283
b"DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED\0",
12811284
"datadog.profiling.experimental_timeline_enabled",

0 commit comments

Comments
 (0)