]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Handle several IO errors cleanly.
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 27 Apr 2009 12:05:38 +0000 (00:05 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 27 Apr 2009 12:05:38 +0000 (00:05 +1200)
helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c
tools/cachemgr.cc

index b06eadb8aeea1828ec6324010ca51ee4b1c8a6c9..80a9c3008c8a57ca3adfe233836e9051a4f3e6c2 100644 (file)
@@ -461,11 +461,13 @@ manage_request()
 int
 main(int argc, char *argv[])
 {
-
     debug("ntlm_auth build " __DATE__ ", " __TIME__ " starting up...\n");
 #ifdef DEBUG
     debug("changing dir to /tmp\n");
-    chdir("/tmp");
+    if (chdir("/tmp") != 0) {
+        debug("ERROR: (%d) failed.\n",errno);
+        return 2;
+    }
 #endif
 
     my_program_name = argv[0];
index 211a29c899e1df53f98e3e0d0feb3a3329289643..b9569cf50194fbe5bb5b0fb493e1088304908bf1 100644 (file)
@@ -871,8 +871,10 @@ process_request(cachemgr_request * req)
                  req->hostname,
                  req->action,
                  make_auth_header(req));
-    write(s, buf, l);
-    debug(1) fprintf(stderr, "wrote request: '%s'\n", buf);
+    if (write(s, buf, l) <0 )
+        debug(1) fprintf(stderr, "ERROR: (%d) writing request: '%s'\n", errno, buf);
+    else
+        debug(1) fprintf(stderr, "wrote request: '%s'\n", buf);
     return read_reply(s, req);
 }
 
@@ -928,7 +930,8 @@ read_post_request(void) {
 
     buf = (char *)xmalloc(len + 1);
 
-    fread(buf, len, 1, stdin);
+    if (fread(buf, len, 1, stdin) == 0)
+        return NULL;
 
     buf[len] = '\0';