From db3d36558deff54e8a47e96933acd4543d7eb05f Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Fri, 23 May 2025 00:40:05 +0000 Subject: When commons were deprecated, noone noticed that malloc_options in static binaries had become unlinkable. Change the libc definition to weak to solve that, and to "const char * const" so that noone will try to set it late. It must be stable before the first malloc() call, which could be before main()... discussion with otto, kettenis, tedu --- src/lib/libc/stdlib/malloc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lib/libc/stdlib/malloc.c') diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index cad8e5d6a1..fa36a3a7f3 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.297 2024/09/20 02:00:46 jsg Exp $ */ +/* $OpenBSD: malloc.c,v 1.298 2025/05/23 00:40:05 deraadt Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek * Copyright (c) 2012 Matthew Dempsky @@ -264,7 +264,8 @@ static union { __attribute__((section(".openbsd.mutable"))); #define mopts malloc_readonly.mopts -char *malloc_options; /* compile-time options */ +/* compile-time options */ +const char *const malloc_options __attribute__((weak)); static __dead void wrterror(struct dir_info *d, char *msg, ...) __attribute__((__format__ (printf, 2, 3))); @@ -501,7 +502,8 @@ omalloc_parseopt(char opt) static void omalloc_init(void) { - char *p, *q, b[16]; + const char *p; + char *q, b[16]; int i, j; const int mib[2] = { CTL_VM, VM_MALLOC_CONF }; size_t sb; -- cgit v1.2.3-55-g6feb