From 30b410e49098c5016b9295263a15c479aec77e86 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Mon, 19 Feb 2024 15:20:51 +0000 Subject: [PATCH] Avoid a segfault in nxt_conn_io_sendbuf() This is a simple temporary fix (doesn't address the underlying problem) for an issue reported by a user on GitHub whereby downloading of files from a PHP application would cause the router process to crash. This is actually a generic problem that will affect anything sending data via nxt_unit_response_write(). This is just a simple fix for the 1.32 release, after which the full correct fix will be worked out. Link: Reported-by: rustedsword Co-developed-by: rustedsword Tested-by: rustedsword Tested-by: Andrew Clayton Reviewed-by: Zhidao Hong Signed-off-by: Andrew Clayton --- src/nxt_conn_write.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/nxt_conn_write.c b/src/nxt_conn_write.c index 714a3e15..7d0a579f 100644 --- a/src/nxt_conn_write.c +++ b/src/nxt_conn_write.c @@ -172,6 +172,13 @@ nxt_conn_io_sendbuf(nxt_task_t *task, nxt_sendbuf_t *sb) return 0; } + /* + * XXX Temporary fix for + */ + if (niov == 0 && sb->buf == NULL) { + return 0; + } + if (niov == 0 && nxt_buf_is_file(sb->buf)) { return nxt_conn_io_sendfile(task, sb); }