Skip to content

Commit 87e50f5

Browse files
committed
askrene: close files in child to isolate against bugs.
This makes sure it cannot interfere with the parent askrene's connection to lightningd, for example. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 029c62c commit 87e50f5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

plugins/askrene/askrene.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,13 @@ static struct command_result *do_getroutes(struct command *cmd,
622622
close(replyfds[0]);
623623
set_child_log_fd(logfds[1]);
624624

625+
/* Make sure we don't stomp over plugin fds, even if we have a bug */
626+
for (int i = 0; i < min_u64(logfds[1], replyfds[1]); i++) {
627+
/* stderr is maintained */
628+
if (i != 2)
629+
close(i);
630+
}
631+
625632
/* Does not return! */
626633
run_child(askrene->gossmap,
627634
layers,

0 commit comments

Comments
 (0)