summaryrefslogtreecommitdiff
path: root/include/glob.h
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-03-19 19:26:06 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-22 05:46:47 +0100
commit1a3d22af2606aceb8e175c318e8632a2030318e4 (patch)
tree8ac894ddf80e6d337b80d9ac1e39f7879a55db95 /include/glob.h
parent9d5beb677dd65647e9cba299e558306c6c4bc8c1 (diff)
downloadbarebox-1a3d22af2606aceb8e175c318e8632a2030318e4.tar.gz
glob: use empty globfree when compiling without CONFIG_GLOB
We already return an error code unconditionally when building with !CONFIG_GLOB. We need to do the same for globfree. Otherwise, we run risk of corrupting memory. This issue exists since the code was first added, but it became more acute with 90cde3b9ff46 ("startup: Execute init scripts in alphabetical order"), which added a globfree into the shell init. Configuration without CONFIG_GLOB would from then on experience memory corruption during startup. Reported-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/glob.h')
-rw-r--r--include/glob.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/glob.h b/include/glob.h
index 5f532e6652..ec0ac66f87 100644
--- a/include/glob.h
+++ b/include/glob.h
@@ -177,6 +177,7 @@ extern int glob __P ((__const char *__restrict __pattern, int __flags,
int (*__errfunc) (__const char *, int),
glob_t *__restrict __pglob));
+extern void globfree __P ((glob_t *__pglob));
#else
static inline int glob __P ((__const char *__restrict __pattern, int __flags,
int (*__errfunc) (__const char *, int),
@@ -184,9 +185,12 @@ static inline int glob __P ((__const char *__restrict __pattern, int __flags,
{
return GLOB_ABORTED;
}
+
+static inline void globfree __P ((glob_t *__pglob))
+{
+}
#endif
/* Free storage allocated in PGLOB by a previous `glob' call. */
-extern void globfree __P ((glob_t *__pglob));
#else
extern int glob __P ((__const char *__restrict __pattern, int __flags,
int (*__errfunc) (__const char *, int),