[PATCH] Fixed crash protection in round robin

乔志奇 qiaozhiqi2016 at gmail.com
Tue Dec 20 08:16:37 UTC 2022


# HG changeset patch
# User 乔志奇@Matebook-Qiao <qiaozhiqi2016 at gmail.com>
# Date 1671521412 -28800
#      Tue Dec 20 15:30:12 2022 +0800
# Branch nginx-bugfix-crash
# Node ID 992013158c8970318c20e2e3294dbc9311bb20c8
# Parent  3108d4d668e4b907868b815f0441d4c893bf4188
Fixed crash protection in round robin

When all servers in the upstream are in the down state, rrp->peers will be
NULL, initialization will crash here, and protection is needed.

diff -r 3108d4d668e4 -r 992013158c89
src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c  Fri Dec 16 01:15:15 2022
+0400
+++ b/src/http/ngx_http_upstream_round_robin.c  Tue Dec 20 15:30:12 2022
+0800
@@ -275,6 +275,10 @@
     rrp->current = NULL;
     rrp->config = 0;

+    if (rrp->peers == NULL) {
+        return NGX_ERROR;
+    }
+
     n = rrp->peers->number;

     if (rrp->peers->next && rrp->peers->next->number > n) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20221220/eb13108d/attachment.htm>


More information about the nginx-devel mailing list