diff options
author | Thomas Haller <thaller@redhat.com> | 2022-02-28 19:12:42 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-03-04 10:05:06 +0100 |
commit | 5cf4d3c7448af0ffe8de918414eedf8b3bb96910 (patch) | |
tree | e310eb1cd96f75591a382848fa1133df68304d91 | |
parent | fbee64e97993c8cd44b088efa7844688ac6998c1 (diff) | |
download | NetworkManager-5cf4d3c7448af0ffe8de918414eedf8b3bb96910.tar.gz |
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.
-rw-r--r-- | src/libnm-glib-aux/nm-glib.h | 10 |
1 files changed, 10 insertions, 0 deletions
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__ */ |