diff --git a/src/tunnel.c b/src/tunnel.c
index 50d6cd378262188c2f0dbcaae7c2d027ddc8a36f..b2691db3fd09457a047ef93dcf5dfd2c04b9dc8a 100644
--- a/src/tunnel.c
+++ b/src/tunnel.c
@@ -456,7 +456,7 @@ static int tcp_connect(struct tunnel *tunnel)
 		                )
 		        )
 		        // condition for buffer full or possibly eof
-		        && (curr_pos < sizeof(request)) && (bytes_read > 0)
+		        && (curr_pos < sizeof(request) - 1) && (bytes_read > 0)
 		);
 		free(env_proxy); // we have copied the string
 	}