aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/spawn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/spawn.c')
-rw-r--r--src/spawn.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/spawn.c b/src/spawn.c
index 716bafa..b17ee58 100644
--- a/src/spawn.c
+++ b/src/spawn.c
@@ -22,6 +22,7 @@
#include <signal.h>
#include <glib.h>
+#include <glib/gprintf.h>
#include <gmodule.h>
@@ -295,6 +296,25 @@ teco_state_execute_done(teco_machine_main_t *ctx, teco_string_t str, GError **er
if (!argv)
goto gerror;
+#if defined(__FreeBSD__) && __FreeBSD__ < 16
+ /*
+ * FIXME: g_spawn_async_with_pipes() will internally call
+ * posix_spawnp() which uses a tiny 4kb stack which can
+ * easily result in memory corruption if the path does not
+ * contain '/', ie. must be resolved against $PATH.
+ * See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295991
+ * As a workaround, only pass down absolute paths.
+ */
+ gchar *program = g_find_program_in_path(argv[0]);
+ if (!program) {
+ g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
+ "Program \"%s\" not found", argv[0]);
+ goto gerror;
+ }
+ g_free(argv[0]);
+ argv[0] = program;
+#endif /* __FreeBSD__ < 16 */
+
envp = teco_qreg_table_get_environ(&teco_qreg_table_globals, error);
if (!envp)
goto gerror;