sks-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2] Recon server check that the HTTP request succeeded before usin


From: Kim Minh Kaplan
Subject: [PATCH 2] Recon server check that the HTTP request succeeded before using the response (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix)
Date: Wed, 25 Mar 2009 14:03:09 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Recon server check that the HTTP request succeeded before using the response.

Kim Minh.

diff -r b49747d1b1d0 -r 38b920ada3e2 reconComm.ml
--- a/reconComm.ml      Wed Mar 25 12:08:39 2009 +0000
+++ b/reconComm.ml      Wed Mar 25 12:14:08 2009 +0000
@@ -65,6 +65,8 @@
   with
       Not_found -> false
 
+let http_status_ok_regexp = Str.regexp "^HTTP/[0-9]+\\.[0-9]+ 2"
+
 let get_keystrings_via_http addr hashes = 
   let s = Unix.socket 
            ~domain:Unix.PF_INET 
@@ -84,7 +86,10 @@
                                     (String.length msg));
                cout#write_string msg;
                cout#flush;
-               ignore (input_line cin#inchan); (* read "HTTP" line *)
+               (* read "HTTP" line and make sure the status is 2xx *)
+               let status = input_line cin#inchan in
+               if not (Str.string_match http_status_ok_regexp status 0) then
+                 failwith status;
                let _headers = Wserver.parse_headers Map.empty cin#inchan in
                let keystrings = 
                  CMarshal.unmarshal_list ~f:CMarshal.unmarshal_string cin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]