Skip to content

Commit 4409b45

Browse files
committed
env_reexec: skip restart if reading env fails
This fixes an edge case out-of-bounds write caught by scan-build
1 parent 524e9f1 commit 4409b45

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

waywall/env_reexec.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ env_reexec(char **argv) {
301301
// to this environment so that we don't enter an infinite loop of reexecuting with a fresh
302302
// environment.
303303
struct list_envvar penv = penv_read(penvbuf);
304+
if (!penv.data) {
305+
goto fail_penv_read;
306+
}
304307

305308
char fd_env[16] = {0};
306309
snprintf(fd_env, STATIC_ARRLEN(fd_env), "%d", passthrough_fd);
@@ -317,6 +320,7 @@ env_reexec(char **argv) {
317320
penv_destroy(&penv);
318321
ww_log_errno(LOG_ERROR, "env_reexec failed");
319322

323+
fail_penv_read:
320324
fail_write_passthrough:
321325
close(passthrough_fd);
322326

0 commit comments

Comments
 (0)