[nginx-quic] fix the infinite loop issue for quic branch

Yu Liu (刘宇)(FU-IBU)(国际业务研发部) liu.yub at trip.com
Thu May 20 10:00:01 UTC 2021


Hi Team,

We tried nginx-quic on our server and found a problem. Please refer to the changeset below.

Regards,
Yu Liu


# HG changeset patch
# User Yu Liu <liu.yub at trip.com<mailto:liu.yub at trip.com>>
# Date 1621502282 -28800
#      Thu May 20 17:18:02 2021 +0800
# Branch quic
# Node ID 4055a366b23e29215f3b4eb1d104303e33266cd4
# Parent  557dc6a06ba6ea7e78444067c4b8fbb022f7b191
Fix the infinite loop issue

When bits is greater than or equal to 3, value is always shifted 62 bits to the right. So when the input number is greater than 2 to the power of 62, this method will loop endlessly.

diff -r 557dc6a06ba6 -r 4055a366b23e src/event/quic/ngx_event_quic_transport.c
--- a/src/event/quic/ngx_event_quic_transport.c Tue May 18 18:17:25 2021 +0300
+++ b/src/event/quic/ngx_event_quic_transport.c Thu May 20 17:18:02 2021 +0800
@@ -250,7 +250,7 @@
     ngx_uint_t  bits;

     bits = 0;
-    while (value >> ((8 << bits) - 2)) {
+    while (bits <=3 && (value >> ((8 << bits) - 2))) {
         bits++;
     }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20210520/1aefd285/attachment.htm>


More information about the nginx-devel mailing list