Skip to content

Commit 50165ab

Browse files
committed
Minor fixes
1 parent cda0bea commit 50165ab

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/HTTPMessage.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ std::string HTTPMessage::getStrElement(char delim) {
150150

151151
// Grab the std::string from the byte buffer up to the delimiter
152152
char *str = new char[size];
153+
bzero(str, size);
153154
getBytes((byte*)str, size);
154155
str[size - 1] = 0x00; // NULL termination
155156
ret.assign(str);

src/HTTPMessage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// Constants
2929
#define HTTP_VERSION_10 "HTTP/1.0"
3030
#define HTTP_VERSION_11 "HTTP/1.1"
31-
#define DEFAULT_HTTP_VERSION "HTTP/1.1"
31+
#define DEFAULT_HTTP_VERSION HTTP_VERSION_11
3232
#define NUM_METHODS 9
3333

3434
// HTTP Methods (Requests)

src/HTTPServer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ HTTPServer::HTTPServer(std::vector<std::string> vhost_aliases, int port, std::st
4444
hostList.push_back(resHost);
4545

4646
// Always serve up localhost/127.0.0.1 (which is why we only added one ResourceHost to hostList above)
47-
char tmpstr[128];
47+
char tmpstr[128] = {0};
4848
sprintf(tmpstr, "localhost:%i", listenPort);
4949
vhosts.insert(std::pair<std::string, ResourceHost*>(std::string(tmpstr).c_str(), resHost));
5050
sprintf(tmpstr, "127.0.0.1:%i", listenPort);
@@ -591,6 +591,7 @@ void HTTPServer::handleTrace(Client* cl, HTTPRequest *req) {
591591
// Get a byte array representation of the request
592592
unsigned int len = req->size();
593593
byte* buf = new byte[len];
594+
bzero(buf, len);
594595
req->setReadPos(0); // Set the read position at the beginning since the request has already been read to the end
595596
req->getBytes(buf, len);
596597

@@ -649,7 +650,7 @@ void HTTPServer::sendResponse(Client* cl, HTTPResponse* resp, bool disconnect) {
649650

650651
// Time stamp the response with the Date header
651652
std::string tstr;
652-
char tbuf[36];
653+
char tbuf[36] = {0};
653654
time_t rawtime;
654655
struct tm* ptm;
655656
time(&rawtime);

0 commit comments

Comments
 (0)