diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp index 66aaeaa9b..36c61e876 100644 --- a/libc/bionic/libc_init_static.cpp +++ b/libc/bionic/libc_init_static.cpp @@ -224,17 +224,14 @@ static bool get_environment_memtag_setting(HeapTaggingLevel* level) { const char* basename = __gnu_basename(progname); - static constexpr size_t kOptionsSize = PROP_VALUE_MAX; - char options_str[kOptionsSize]; - size_t sysprop_size = strlen(basename) + strlen(kMemtagPrognameSyspropPrefix) + 1; - char* sysprop_name = static_cast(alloca(sysprop_size)); - - async_safe_format_buffer(sysprop_name, sysprop_size, "%s%s", kMemtagPrognameSyspropPrefix, + char options_str[PROP_VALUE_MAX]; + char sysprop_name[512]; + async_safe_format_buffer(sysprop_name, sizeof(sysprop_name), "%s%s", kMemtagPrognameSyspropPrefix, basename); const char* sys_prop_names[] = {sysprop_name, kMemtagGlobalSysprop}; if (!get_config_from_env_or_sysprops("MEMTAG_OPTIONS", sys_prop_names, arraysize(sys_prop_names), - options_str, kOptionsSize)) { + options_str, sizeof(options_str))) { return false; }