Browse Source

fix reverse proxy buffer overflow (#520)

fn_MrRice 1 year ago
parent
commit
a62230762c
2 changed files with 2 additions and 1 deletions
  1. 1 0
      http/HttpMessage.h
  2. 1 1
      http/server/HttpHandler.cpp

+ 1 - 0
http/HttpMessage.h

@@ -297,6 +297,7 @@ public:
     void* Content() {
     void* Content() {
         if (content == NULL && body.size() != 0) {
         if (content == NULL && body.size() != 0) {
             content = (void*)body.data();
             content = (void*)body.data();
+            content_length = body.size();
         }
         }
         return content;
         return content;
     }
     }

+ 1 - 1
http/server/HttpHandler.cpp

@@ -1098,7 +1098,7 @@ int HttpHandler::sendProxyRequest() {
     req->headers["Connection"] = keepalive ? "keep-alive" : "close";
     req->headers["Connection"] = keepalive ? "keep-alive" : "close";
     req->headers["X-Real-IP"] = ip;
     req->headers["X-Real-IP"] = ip;
     // NOTE: send head + received body
     // NOTE: send head + received body
-    std::string msg = req->Dump(true, true);
+    std::string msg = req->Dump(true, false) + req->body;
     // printf("%s\n", msg.c_str());
     // printf("%s\n", msg.c_str());
     req->Reset();
     req->Reset();