From: Amos Jeffries Date: Sun, 3 May 2009 11:48:43 +0000 (+1200) Subject: Handle several IO errors cleanly. X-Git-Tag: SQUID_3_1_0_8~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4c1bb178d5bc1473eccc105bf90de0897849f885;p=thirdparty%2Fsquid.git Handle several IO errors cleanly. --- diff --git a/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c b/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c index 7c97d14395..7789497795 100644 --- a/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c +++ b/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c @@ -451,11 +451,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]; diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index 211a29c899..39aa118968 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -871,8 +871,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); } @@ -928,7 +931,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';