]> git.kaiwu.me - nginx.git/commitdiff
Request body: added alert to catch duplicate body saving.
authorMaxim Dounin <mdounin@mdounin.ru>
Sun, 29 Aug 2021 19:20:54 +0000 (22:20 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Sun, 29 Aug 2021 19:20:54 +0000 (22:20 +0300)
If due to an error ngx_http_request_body_save_filter() is called
more than once with rb->rest == 0, this used to result in a segmentation
fault.  Added an alert to catch such errors, just in case.

src/http/ngx_http_request_body.c

index b72614ff9fe15fbbed85aa031419cf8e0d302d82..c5401fd42e447019ddc55f1ebcc98d49869f18f2 100644 (file)
@@ -1246,6 +1246,12 @@ ngx_http_request_body_save_filter(ngx_http_request_t *r, ngx_chain_t *in)
 
     if (rb->temp_file || r->request_body_in_file_only) {
 
+        if (rb->bufs && rb->bufs->buf->in_file) {
+            ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+                          "body already in file");
+            return NGX_HTTP_INTERNAL_SERVER_ERROR;
+        }
+
         if (ngx_http_write_request_body(r) != NGX_OK) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }