소스 검색

fix reverse proxy buffer overflow (#520)

fn_MrRice 1 년 전
부모
커밋
a62230762c
2개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  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() {
         if (content == NULL && body.size() != 0) {
             content = (void*)body.data();
+            content_length = body.size();
         }
         return content;
     }

+ 1 - 1
http/server/HttpHandler.cpp

@@ -1098,7 +1098,7 @@ int HttpHandler::sendProxyRequest() {
     req->headers["Connection"] = keepalive ? "keep-alive" : "close";
     req->headers["X-Real-IP"] = ip;
     // 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());
     req->Reset();