From: wessels <> Date: Thu, 1 May 1997 04:46:23 +0000 (+0000) Subject: Fixed ACL_SRC_DOMAIN that should have been ACL_DST_DOMAIN bug X-Git-Tag: SQUID_3_0_PRE1~5031 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7a22b88739c5f5aacd52a7f8166322d10b7bdc9;p=thirdparty%2Fsquid.git Fixed ACL_SRC_DOMAIN that should have been ACL_DST_DOMAIN bug Other purify fixes --- diff --git a/src/acl.cc b/src/acl.cc index fd2ac7f9cf..6026939364 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,5 +1,5 @@ /* - * $Id: acl.cc,v 1.92 1997/04/30 20:06:23 wessels Exp $ + * $Id: acl.cc,v 1.93 1997/04/30 22:46:23 wessels Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -1064,7 +1064,7 @@ aclMatchAcl(struct _acl *acl, aclCheck_t * checklist) } else if (checklist->state[ACL_DST_IP] == ACL_LOOKUP_NONE) { debug(28, 3, "aclMatchAcl: Can't yet compare '%s' ACL for '%s'\n", acl->name, r->host); - checklist->state[ACL_DST_IP] = ACL_LOOKUP_NEED; + checklist->state[ACL_DST_IP] = ACL_LOOKUP_NEEDED; return 0; } else { return aclMatchIp(&acl->data, no_addr); @@ -1079,7 +1079,7 @@ aclMatchAcl(struct _acl *acl, aclCheck_t * checklist) if (checklist->state[ACL_DST_DOMAIN] == ACL_LOOKUP_NONE) { debug(28, 3, "aclMatchAcl: Can't yet compare '%s' ACL for '%s'\n", acl->name, inet_ntoa(ia->in_addrs[0])); - checklist->state[ACL_DST_DOMAIN] = ACL_LOOKUP_NEED; + checklist->state[ACL_DST_DOMAIN] = ACL_LOOKUP_NEEDED; return 0; } return aclMatchDomainList(&acl->data, "none"); @@ -1091,7 +1091,7 @@ aclMatchAcl(struct _acl *acl, aclCheck_t * checklist) } else if (checklist->state[ACL_SRC_DOMAIN] == ACL_LOOKUP_NONE) { debug(28, 3, "aclMatchAcl: Can't yet compare '%s' ACL for '%s'\n", acl->name, inet_ntoa(checklist->src_addr)); - checklist->state[ACL_SRC_DOMAIN] = ACL_LOOKUP_NEED; + checklist->state[ACL_SRC_DOMAIN] = ACL_LOOKUP_NEEDED; return 0; } else { return aclMatchDomainList(&acl->data, "none"); @@ -1172,34 +1172,31 @@ aclCheck(aclCheck_t * checklist) debug(28, 3, "aclCheck: checking '%s'\n", A->cfgline); allow = A->allow; match = aclMatchAclList(A->acl_list, checklist); - if (checklist->state[ACL_DST_IP] == ACL_LOOKUP_NEED) { + if (checklist->state[ACL_DST_IP] == ACL_LOOKUP_NEEDED) { checklist->state[ACL_DST_IP] = ACL_LOOKUP_PENDING; ipcache_nbgethostbyname(checklist->request->host, -1, aclLookupDstIPDone, checklist); - checklist->dst_ip_lookup_pending = 1; return; - } else if (checklist->state[ACL_SRC_DOMAIN] == ACL_LOOKUP_NEED) { + } else if (checklist->state[ACL_SRC_DOMAIN] == ACL_LOOKUP_NEEDED) { checklist->state[ACL_SRC_DOMAIN] = ACL_LOOKUP_PENDING; fqdncache_nbgethostbyaddr(checklist->src_addr, -1, aclLookupSrcFQDNDone, checklist); - checklist->src_fqdn_lookup_pending = 1; return; - } else if (checklist->state[ACL_DST_DOMAIN] == ACL_LOOKUP_NEED) { + } else if (checklist->state[ACL_DST_DOMAIN] == ACL_LOOKUP_NEEDED) { checklist->dst_ia = ipcacheCheckNumeric(checklist->request->host); - if (checklist->dst_ia != NULL) { - checklist->state[ACL_DST_DOMAIN] = ACL_LOOKUP_PENDING; - fqdncache_nbgethostbyaddr(checklist->dst_ia->in_addrs[0], - -1, - aclLookupDstFQDNDone, - checklist); - checklist->dst_fqdn_lookup_pending = 1; - } else { + if (checklist->dst_ia == NULL) { checklist->state[ACL_DST_DOMAIN] = ACL_LOOKUP_DONE; + return; } + checklist->state[ACL_DST_DOMAIN] = ACL_LOOKUP_PENDING; + fqdncache_nbgethostbyaddr(checklist->dst_ia->in_addrs[0], + -1, + aclLookupDstFQDNDone, + checklist); return; } if (match) { @@ -1219,11 +1216,11 @@ aclCheckCallback(aclCheck_t * checklist, int answer) { debug(28, 3, "aclCheckCallback: answer=%d\n", answer); checklist->callback(answer, checklist->callback_data); - if (checklist->src_fqdn_lookup_pending) + if (checklist->state[ACL_SRC_DOMAIN] == ACL_LOOKUP_PENDING) fqdncacheUnregister(checklist->src_addr, checklist); - if (checklist->dst_fqdn_lookup_pending) + if (checklist->state[ACL_DST_DOMAIN] == ACL_LOOKUP_PENDING) fqdncacheUnregister(checklist->dst_ia->in_addrs[0], checklist); - if (checklist->dst_ip_lookup_pending) + if (checklist->state[ACL_DST_IP] == ACL_LOOKUP_PENDING) ipcacheUnregister(checklist->request->host, checklist); requestUnlink(checklist->request); xfree(checklist); @@ -1233,7 +1230,6 @@ static void aclLookupDstIPDone(int fd, const ipcache_addrs * ia, void *data) { aclCheck_t *checklist = data; - checklist->dst_ip_lookup_pending = 0; checklist->state[ACL_DST_IP] = ACL_LOOKUP_DONE; aclCheck(checklist); } @@ -1242,7 +1238,6 @@ static void aclLookupSrcFQDNDone(int fd, const char *fqdn, void *data) { aclCheck_t *checklist = data; - checklist->src_fqdn_lookup_pending = 0; checklist->state[ACL_SRC_DOMAIN] = ACL_LOOKUP_DONE; aclCheck(checklist); } @@ -1251,8 +1246,7 @@ static void aclLookupDstFQDNDone(int fd, const char *fqdn, void *data) { aclCheck_t *checklist = data; - checklist->dst_fqdn_lookup_pending = 0; - checklist->state[ACL_SRC_DOMAIN] = ACL_LOOKUP_DONE; + checklist->state[ACL_DST_DOMAIN] = ACL_LOOKUP_DONE; aclCheck(checklist); } diff --git a/src/disk.cc b/src/disk.cc index 97562e7a8c..2fd577a3ba 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -1,5 +1,5 @@ /* - * $Id: disk.cc,v 1.65 1997/04/30 20:06:26 wessels Exp $ + * $Id: disk.cc,v 1.66 1997/04/30 22:46:25 wessels Exp $ * * DEBUG: section 6 Disk I/O Routines * AUTHOR: Harvest Derived @@ -396,8 +396,10 @@ file_write(int fd, void (*free_func) _PARAMS((void *))) { dwrite_q *wq = NULL; - FD_ENTRY *fde = &fd_table[fd]; - + FD_ENTRY *fde; + if (fd < 0) + fatal_dump("file_write: bad FD"); + fde = &fd_table[fd]; if (!fde->open) { debug_trap("file_write: FILE_NOT_OPEN"); return DISK_ERROR; diff --git a/src/neighbors.cc b/src/neighbors.cc index 29ccb7c471..92d3e26186 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,5 +1,5 @@ /* - * $Id: neighbors.cc,v 1.136 1997/04/30 20:06:32 wessels Exp $ + * $Id: neighbors.cc,v 1.137 1997/04/30 22:46:26 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -1106,8 +1106,10 @@ peerCountMcastPeersDone(void *data) p->mcast.avg_n_members); p->mcast.n_replies_expected = (int) p->mcast.avg_n_members; fake->store_status = STORE_ABORTED; + requestUnlink(fake->mem_obj->request); storeReleaseRequest(fake); storeUnlockObject(fake); + requestUnlink(psstate->request); xfree(psstate); } diff --git a/src/redirect.cc b/src/redirect.cc index c2d731b015..30ce6067f8 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,5 +1,5 @@ /* - * $Id: redirect.cc,v 1.39 1997/04/30 18:30:59 wessels Exp $ + * $Id: redirect.cc,v 1.40 1997/04/30 22:46:26 wessels Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -77,6 +77,7 @@ static PF redirectHandleRead; static redirectStateData *Dequeue _PARAMS((void)); static void Enqueue _PARAMS((redirectStateData *)); static void redirectDispatch _PARAMS((redirector_t *, redirectStateData *)); +static void redirectStateFree _PARAMS((redirectStateData * r)); static redirector_t **redirect_child_table = NULL; static int NRedirectors = 0; @@ -220,7 +221,7 @@ redirectHandleRead(int fd, void *data) r->handler(r->data, t == redirector->inbuf ? NULL : redirector->inbuf); } - safe_free(r); + redirectStateFree(r); redirector->redirectState = NULL; redirector->flags &= ~REDIRECT_FLAG_BUSY; redirector->offset = 0; @@ -279,6 +280,13 @@ GetFirstAvailable(void) return NULL; } +static void +redirectStateFree(redirectStateData * r) +{ + safe_free(r->orig_url); + safe_free(r); +} + static void redirectDispatch(redirector_t * redirect, redirectStateData * r) @@ -289,7 +297,7 @@ redirectDispatch(redirector_t * redirect, redirectStateData * r) if (r->handler == NULL) { debug(29, 1, "redirectDispatch: skipping '%s' because no handler\n", r->orig_url); - safe_free(r); + redirectStateFree(r); return; } redirect->flags |= REDIRECT_FLAG_BUSY; @@ -337,7 +345,7 @@ redirectStart(int cfd, icpStateData * icpState, RH * handler, void *data) } r = xcalloc(1, sizeof(redirectStateData)); r->fd = cfd; - r->orig_url = icpState->url; + r->orig_url = xstrdup(icpState->url); r->client_addr = icpState->log_addr; if (icpState->ident.ident == NULL || *icpState->ident.ident == '\0') { r->client_ident = dash_str; diff --git a/src/store.cc b/src/store.cc index c0991b38ee..dbc8254796 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.226 1997/04/30 16:18:44 wessels Exp $ + * $Id: store.cc,v 1.227 1997/04/30 22:46:27 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -2454,7 +2454,6 @@ storeInitHashValues(void) void storeInit(void) { - int dir_created = 0; char *fname = NULL; storeInitHashValues(); storeCreateHashTable(urlcmp); @@ -2466,8 +2465,8 @@ storeInit(void) debug(20, 1, "Store logging disabled\n"); if (ncache_dirs < 1) fatal("No cache_dir's specified in config file"); - dir_created = storeVerifySwapDirs(); - + storeVerifySwapDirs(); + storeDirOpenSwapLogs(); if (!opt_zap_disk_store) storeStartRebuildFromDisk(); else diff --git a/src/store_dir.cc b/src/store_dir.cc index accd04c9f1..3123decad3 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -274,6 +274,7 @@ storeDirOpenSwapLogs(void) debug(50, 1, "%s: %s\n", path, xstrerror()); fatal("storeDirOpenSwapLogs: Failed to open swap log."); } + debug(20, 3, "Cache Dir #%d log opened on FD %d\n", i, fd); SD->swaplog_fd = fd; } } @@ -286,6 +287,8 @@ storeDirCloseSwapLogs(void) for (i = 0; i < ncache_dirs; i++) { SD = &SwapDirs[i]; file_close(SD->swaplog_fd); + debug(20, 3, "Cache Dir #%d log closed on FD %d\n", i, SD->swaplog_fd); + SD->swaplog_fd = -1; } } @@ -307,7 +310,6 @@ storeDirOpenTmpSwapLog(int dirn, int *clean_flag) safe_free(new_path); return NULL; } - debug(20, 1, "Rebuilding storage from %s\n", swaplog_path); /* close the existing write-only FD */ if (SD->swaplog_fd >= 0) file_close(SD->swaplog_fd); @@ -354,7 +356,10 @@ storeDirCloseTmpSwapLog(int dirn) debug(50, 1, "%s: %s\n", swaplog_path, xstrerror()); fatal("storeDirCloseTmpSwapLog: Failed to open swap log."); } + safe_free(swaplog_path); + safe_free(new_path); SD->swaplog_fd = fd; + debug(20, 3, "Cache Dir #%d log opened on FD %d\n", i, fd); } void