From: Amos Jeffries Date: Sun, 3 May 2009 12:20:42 +0000 (+1200) Subject: Handle several IO errors cleanly. X-Git-Tag: SQUID_3_0_STABLE15~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80c157e6526a62372132e618ca1618803d9c7839;p=thirdparty%2Fsquid.git Handle several IO errors cleanly. --- diff --git a/helpers/ntlm_auth/SMB/ntlm_auth.c b/helpers/ntlm_auth/SMB/ntlm_auth.c index d4013ae6e8..41e9c6d1d5 100644 --- a/helpers/ntlm_auth/SMB/ntlm_auth.c +++ b/helpers/ntlm_auth/SMB/ntlm_auth.c @@ -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]; diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index 611176b160..44cd3e9c0c 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -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';