dropbear: cherry-pick upstream patches
[openwrt/staging/robimarko.git] / package / network / services / dropbear / patches / 009-use-write-rather-than-fprintf-in-segv-handler.patch
1 From 3292b8c6f1e5fcc405fa0f7a20e90a60f74037b2 Mon Sep 17 00:00:00 2001
2 From: Matt Johnston <matt@ucc.asn.au>
3 Date: Sun, 12 Feb 2023 23:00:00 +0800
4 Subject: Use write() rather than fprintf() in segv handler
5
6 fprintf isn't guaranteed safe (though hasn't had any problems reported).
7 ---
8 svr-main.c | 8 ++++++--
9 1 file changed, 6 insertions(+), 2 deletions(-)
10
11 --- a/svr-main.c
12 +++ b/svr-main.c
13 @@ -420,8 +420,12 @@ static void sigchld_handler(int UNUSED(u
14
15 /* catch any segvs */
16 static void sigsegv_handler(int UNUSED(unused)) {
17 - fprintf(stderr, "Aiee, segfault! You should probably report "
18 - "this as a bug to the developer\n");
19 + int i;
20 + const char *msg = "Aiee, segfault! You should probably report "
21 + "this as a bug to the developer\n";
22 + i = write(STDERR_FILENO, msg, strlen(msg));
23 + /* ignore short writes */
24 + (void)i;
25 _exit(EXIT_FAILURE);
26 }
27