program crashes with "Segmentation Fault" in multiple situations because of missing time.h header
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
micro-proxy (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Steps to reproduce:
$ printf "GET https:/
HTTP/1.0 400 Bad Request
Server: micro_proxy
Segmentation fault
$ printf "GET http://
HTTP/1.0 404 Not Found
Server: micro_proxy
Segmentation fault
Fix:
diff --git a/micro_proxy.c b/micro_proxy.c
index 78e317f..3d6c144 100644
--- a/micro_proxy.c
+++ b/micro_proxy.c
@@ -38,6 +38,8 @@
#include <netdb.h>
#include <fcntl.h>
#include <syslog.h>
+#include <time.h>
After fix:
$ printf "GET http://
HTTP/1.0 404 Not Found
Server: micro_proxy
Date: Mon, 28 May 2018 13:11:48 GMT
Content-Type: text/html
Connection: close
<HTML>
<HEAD><TITLE>404 Not Found</
<BODY BGCOLOR="#cc9999" TEXT="#000000" LINK="#2020ff" VLINK="#4040cc">
<H4>404 Not Found</H4>
Unknown host.
<HR>
<ADDRESS><A HREF="http://
</BODY>
</HTML>
$ printf "GET https:/
HTTP/1.0 400 Bad Request
Server: micro_proxy
Date: Mon, 28 May 2018 13:12:02 GMT
Content-Type: text/html
Connection: close
<HTML>
<HEAD><TITLE>400 Bad Request<
<BODY BGCOLOR="#cc9999" TEXT="#000000" LINK="#2020ff" VLINK="#4040cc">
<H4>400 Bad Request</H4>
Unknown URL type.
<HR>
<ADDRESS><A HREF="http://
</BODY>
</HTML>