]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
*) mod_http2: fix edge case in removal of entries
authorStefan Eissing <icing@apache.org>
Thu, 21 Apr 2022 10:31:37 +0000 (10:31 +0000)
committerStefan Eissing <icing@apache.org>
Thu, 21 Apr 2022 10:31:37 +0000 (10:31 +0000)
     in a h2_fifo.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1900102 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_util.c

index ef0062885e69afd6358b71250576ff21ef65d15c..467d01db2f9736bd685a938d333a87a641282314 100644 (file)
@@ -817,7 +817,7 @@ apr_status_t h2_fifo_remove(h2_fifo *fifo, void *elem)
                         fifo->out -= fifo->capacity;
                     }
                 }
-                else if (i + 1 == fifo->in) {
+                else if (((i + 1) % fifo->capacity) == fifo->in) {
                     /* last element */
                     --fifo->in;
                     if (fifo->in < 0) {
@@ -835,6 +835,8 @@ apr_status_t h2_fifo_remove(h2_fifo *fifo, void *elem)
                 }
                 else {
                     /* we wrapped around, move elements above down */
+                    AP_DEBUG_ASSERT((fifo->in - i - 1) > 0);
+                    AP_DEBUG_ASSERT((fifo->in - i - 1) < fifo->capacity);
                     memmove(&fifo->elems[i], &fifo->elems[i + 1],
                             (fifo->in - i - 1) * sizeof(void*));
                     --fifo->in;