From 27914298f5d277a6f202bfc0b860a010cb8b1676 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Mon, 1 Aug 2022 15:02:25 -0700 Subject: [PATCH] [MTE] use static buffer for per-process property name. Change-Id: I3b0d0fdffe72aef7d66544fecac18f7a097ddbaf --- libc/bionic/libc_init_static.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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; }