From 5cf4d3c7448af0ffe8de918414eedf8b3bb96910 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 28 Feb 2022 19:12:42 +0100 Subject: [PATCH] glib-aux: hide API g_alloca0() and g_newa0() For one, this API is only available since 2.72, thus we must not use it (unless we would add a compat implementation to nm-glib.h). But also, g_alloca0() evaluates the size argument multiple times, making it non-function like. That seems highly undesirable and error prone. Also, we should be very careful about alloca() and the potential for stack overflow. We use alloca() at times, but usually with macros that are named "*_a()" (to make the danger clearer) and compile time checks for the size. These glib functions make this slightly less safe. Just prevent us from using this API. --- src/libnm-glib-aux/nm-glib.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libnm-glib-aux/nm-glib.h b/src/libnm-glib-aux/nm-glib.h index 4ab9cbbda8..f3be3b32a4 100644 --- a/src/libnm-glib-aux/nm-glib.h +++ b/src/libnm-glib-aux/nm-glib.h @@ -717,4 +717,14 @@ _nm_deprecated("Don't use this API") void _nm_forbidden_glib_api_n(gconstpointer /*****************************************************************************/ +/* g_alloca0() evaluates the "size" argument multiple times. That seems an error + * prone API (as it's not function-like). + * + * We could fix it by using an expression statement. But it doesn't seem + * worth it, so hide it to prevent its use. */ +#undef g_alloca0 +#undef g_newa0 + +/*****************************************************************************/ + #endif /* __NM_GLIB_H__ */