]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Handle several IO errors cleanly.
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 3 May 2009 12:20:42 +0000 (00:20 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 3 May 2009 12:20:42 +0000 (00:20 +1200)
helpers/ntlm_auth/SMB/ntlm_auth.c
tools/cachemgr.cc

index d4013ae6e83ddc67d217d3df47a6c5935051dfdc..41e9c6d1d538718de000246f108ae4fce4ccd440 100644 (file)
@@ -452,11 +452,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 611176b1605308c085f1c4a9527eaa35f3778a7c..44cd3e9c0c9700b998b32de2abc4f331007dd7f4 100644 (file)
@@ -874,8 +874,11 @@ 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);
 }
 
@@ -934,7 +937,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';