From: Amos Jeffries Date: Mon, 27 Apr 2009 12:05:38 +0000 (+1200) Subject: Handle several IO errors cleanly. X-Git-Tag: SQUID_3_2_0_1~1035 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdcd85c36c1373c6ba80618405bcfe36d1ae9601;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 b06eadb8ae..80a9c3008c 100644 --- a/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c +++ b/helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c @@ -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]; diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index 211a29c899..b9569cf501 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -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';