program crashes with "Segmentation Fault" in multiple situations because of missing time.h header

Bug #1773802 reported by Mateusz Adamowski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
micro-proxy (Ubuntu)
New
Undecided
Unassigned

Bug Description

Steps to reproduce:

$ printf "GET https://ip.pr1v.net/ HTTP/1.0\r\n\r\n" | ./micro_proxy
HTTP/1.0 400 Bad Request
Server: micro_proxy
Segmentation fault

$ printf "GET http://incorrect.address.00000/ HTTP/1.0\r\n\r\n" | ./micro_proxy
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://incorrect.address.00000/ HTTP/1.0\r\n\r\n" | ./micro_proxy
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</TITLE></HEAD>
<BODY BGCOLOR="#cc9999" TEXT="#000000" LINK="#2020ff" VLINK="#4040cc">
<H4>404 Not Found</H4>
Unknown host.
<HR>
<ADDRESS><A HREF="http://www.acme.com/software/micro_proxy/">micro_proxy</A></ADDRESS>
</BODY>
</HTML>

$ printf "GET https://ip.pr1v.net/ HTTP/1.0\r\n\r\n" | ./micro_proxy
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</TITLE></HEAD>
<BODY BGCOLOR="#cc9999" TEXT="#000000" LINK="#2020ff" VLINK="#4040cc">
<H4>400 Bad Request</H4>
Unknown URL type.
<HR>
<ADDRESS><A HREF="http://www.acme.com/software/micro_proxy/">micro_proxy</A></ADDRESS>
</BODY>
</HTML>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.