Compare commits

..
17 Commits
Author SHA1 Message Date
cvs2svn 7b09d88a75 This commit was manufactured by cvs2svn to create tag 'rel_1-4-2-2'. 2001-09-04 18:31:44 +00:00
Robert James Kaes 05cc60042e New news. :) 2001-09-04 18:31:43 +00:00
Robert James Kaes 11cbe6cb5b More updates. 2001-09-04 18:22:12 +00:00
Robert James Kaes c937858ec1 Moved the compare_header() test after the skip header test. 2001-09-04 18:22:00 +00:00
Robert James Kaes 667b9d5d53 Switched to a case insensitive search method. 2001-09-04 17:53:41 +00:00
Robert James Kaes 0094d2755b Bumped the version number. 2001-09-04 16:52:04 +00:00
Robert James Kaes b095c7a84d Updates. 2001-09-04 16:50:45 +00:00
Robert James Kaes 45a021a18b Fixed a format string bug with the syslog function. 2001-09-04 16:50:22 +00:00
Robert James Kaes aac5f60602 Headers MUST have quotes around them. 2001-08-31 15:20:56 +00:00
Robert James Kaes 2857b4be36 Spelling and grammar fixes. 2001-08-30 22:00:36 +00:00
Robert James Kaes 2577811738 New information for Thursday, August 30, 2001 2001-08-30 16:58:41 +00:00
Robert James Kaes 66012c4e8e Another new version. 2001-08-30 16:54:04 +00:00
Robert James Kaes c825db8d56 More fixes. 2001-08-30 16:53:36 +00:00
Robert James Kaes fc94a56f56 Removed the xstrstr() function since it is no longer used. reqs.c was the
only place it was called from, and strstr() will do the same work.
2001-08-30 16:52:56 +00:00
Robert James Kaes a328cefbf0 Renamed ternary_insert() to ternary_insert_replace() and added the ability
to replace existing data (without a memory leak.) Added two DEFINES
ternary_insert() and ternary_replace() to aid in coding.
2001-08-30 16:52:09 +00:00
Robert James Kaes 22bdb8123d Replaced the call to xstrstr() with strstr(). 2001-08-30 16:51:10 +00:00
Robert James Kaes c83c92a0d1 Removed the insert_data() function and made the LOCKing go around the
entire dnscache() function. Replaced the "replace" code in dns_insert()
with a call to ternary_replace().
2001-08-30 16:50:42 +00:00
11 changed files with 103 additions and 126 deletions

No files matched your search

+36
View File
@@ -1,3 +1,39 @@
2001-09-04 Robert James Kaes <rjkaes@flarenet.com>
* src/reqs.c (process_client_headers): Moved the skip header test
in front of the compare_header() function.
* src/ternary.c (ternary_search): Switched to doing case
insensitive searching.
* src/log.c (log_message): Thanks to NeilK for finding and fixing
a problem with the syslog code which can lead to a format string
attack.
2001-08-30 Robert James Kaes <rjkaes@flarenet.com>
* src/dnscache.c: Removed the insert_data() function and replaced
the "replace" logic in dns_insert() with a call to
ternary_replace(). This fixes the segmentation fault problem which
I introduced when I "tried" to fix the memory leak. Also changed
the LOCKing to be around the entire dnscache() again since I still
need to work out how locking should be done when accessing the
ternary tree.
* src/ternary.c (ternary_insert_replace): Renamed ternary_insert()
to ternary_insert_replace() and added a extra argument. The
function can now "replace" data already in the tree without
causing a memory leak. Added two DEFINES to make coding easier:
ternary_insert() and ternary_replace() which both call this
function with the right arguments.
* src/utils.c: Removed xstrstr() since it was only used in one
place, and could be safely replaced with strstr. I can't even
remember why we had this function to begin with.
* src/reqs.c (compare_header): Removed the call to xstrstr() since
it's been removed from the source.
2001-08-28 Robert James Kaes <rjkaes@flarenet.com>
* src/log.c (log_message): Handle a debug enabled compile better.
+20 -19
View File
@@ -1,25 +1,26 @@
Wednesday, August 29, 2001
Tuesday, September 4, 2001
--------------------------
There has been a tonne of work done on tinyproxy since the beginning
of last week. I have been releasing minor-minor-minor point releases,
but the changes in this release constitute a minor-minor point
release. Please see the ChangeLog for detail descriptions of all the
changes, but here is a brief list.
I finally fixed a problem with the anonymous header code. The searches
are now all case insensitive. This fixes a problem where the spelling
of the HTTP headers could be different. It also helps with various
spellings of domain names. There is also a security fix for a format
string problem with the syslog feature. This problem doesn't affect
you if you use the log file instead.
The most serious fix is to the DNS caching system. There was a memory
leak in the system whenever a domain was already in the database, but
had expired. The new domain information was placed in the database,
but the old information wasn't freed.
-- Robert
The second change is in regard to the regular expression library. For
a while now tinyproxy has included it's own library (the GNU version)
in case the system did not have a working copy. Due to a bug in the
configure.in script the included REGEX library was being used even if
a working copy was detected. This was making tinyproxy larger than it
needed.
I would suggest that everyone upgrade to this version; especially
anyone who is still running 1.4.0 or below.
Thursday, August 30, 2001
-------------------------
-- Robert
Maybe I just shouldn't be working on the code base this week. The
memory fix I added in the last release contained a serious bug which
would cause a segmentation fault. I actually fixed this by removing
the code I added and just fixing the problem in ternary_insert()
instead. I don't know why I didn't do this in the first place. I also
removed the xstrstr() function since strstr() will do what tinyproxy
needs. Removing code is _always_ a good idea. Less code, less chance
of bugs.
-- Robert
+2 -2
View File
@@ -1,4 +1,4 @@
dnl $Id: configure.in,v 1.23 2001-08-29 15:29:29 rjkaes Exp $
dnl $Id: configure.in,v 1.25 2001-09-04 16:52:04 rjkaes Exp $
dnl Devlopers, please strive to achieve this order:
dnl
@@ -19,7 +19,7 @@ AC_INIT()
AC_CANONICAL_SYSTEM
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
AM_INIT_AUTOMAKE(tinyproxy,1.4.2)
AM_INIT_AUTOMAKE(tinyproxy,1.4.2.2)
AM_CONFIG_HEADER(config.h)
dnl
+3 -2
View File
@@ -114,6 +114,7 @@ Allow 192.168.1.0/25
# If an Anonymous keyword is present, then anonymous proxying is enabled.
# The headers listed are allowed through, while all others are denied. If
# no Anonymous keyword is present, then all header are allowed through.
# You must include quotes around the headers.
#
#Anonymous Host
#Anonymous Authorization
#Anonymous "Host"
#Anonymous "Authorization"
+14 -56
View File
@@ -1,4 +1,4 @@
/* $Id: dnscache.c,v 1.10 2001-08-29 03:57:51 rjkaes Exp $
/* $Id: dnscache.c,v 1.11 2001-08-30 16:50:42 rjkaes Exp $
*
* This is a caching DNS system. When a host name is needed we look it up here
* and see if there is already an answer for it. The domains are placed in a
@@ -51,20 +51,6 @@ struct dnscache_s {
static TERNARY dns_tree = -1;
/*
* Insert the data into the DNS tree.
*/
static int insert_data(char *domain, struct dnscache_s *newptr)
{
int ret;
LOCK();
ret = ternary_insert(dns_tree, domain, newptr);
UNLOCK();
return ret;
}
static int dns_lookup(struct in_addr *addr, char *domain)
{
int ret;
@@ -73,17 +59,14 @@ static int dns_lookup(struct in_addr *addr, char *domain)
assert(addr != NULL);
assert(domain != NULL);
LOCK();
ret = ternary_search(dns_tree, domain, (void *)&ptr);
if (TE_ISERROR(ret)
|| difftime(time(NULL), ptr->expire) > DNSEXPIRE) {
UNLOCK();
return -1;
}
memcpy(addr, &ptr->ipaddr, sizeof(struct in_addr));
UNLOCK();
return 0;
}
@@ -91,7 +74,6 @@ static int dns_lookup(struct in_addr *addr, char *domain)
static int dns_insert(struct in_addr *addr, char *domain)
{
struct dnscache_s *newptr;
int ret;
assert(addr != NULL);
assert(domain != NULL);
@@ -105,37 +87,9 @@ static int dns_insert(struct in_addr *addr, char *domain)
memcpy(&newptr->ipaddr, addr, sizeof(struct in_addr));
newptr->expire = time(NULL);
ret = insert_data(domain, newptr);
if (TE_ISERROR(ret)) {
if (ret == TE_EXISTS) {
/*
* The value already exists. First search for the
* value and then delete the data before inserting
* the new value.
*/
struct dnscache_s *existing;
DEBUG2("[%s] already exists in DNS cache", domain);
LOCK();
ret = ternary_search(dns_tree, domain, (void *)&existing);
UNLOCK();
if (TE_ISERROR(ret))
goto INSERT_ERROR;
safefree(existing);
ret = insert_data(domain, newptr);
if (TE_ISERROR(ret))
goto INSERT_ERROR;
} else {
INSERT_ERROR:
safefree(newptr);
return -1;
}
if (TE_ISERROR(ternary_replace(dns_tree, domain, newptr))) {
safefree(newptr);
return -1;
}
return 0;
@@ -148,30 +102,34 @@ int dnscache(struct in_addr *addr, char *domain)
assert(addr != NULL);
assert(domain != NULL);
/* If the DNS tree doesn't exist, build a new one */
LOCK();
/* If the DNS tree doesn't exist, build a new one */
if (dns_tree < 0)
dns_tree = ternary_new();
UNLOCK();
if (inet_aton(domain, (struct in_addr *)addr) != 0)
if (inet_aton(domain, (struct in_addr *)addr) != 0) {
UNLOCK();
return 0;
}
/* Well, we're not dotted-decimal so we need to look it up */
if (dns_lookup(addr, domain) == 0)
if (dns_lookup(addr, domain) == 0) {
UNLOCK();
return 0;
}
/* Okay, so not in the list... need to actually look it up. */
LOCK();
if (!(resolv = gethostbyname(domain))) {
UNLOCK();
return -1;
}
memcpy(addr, resolv->h_addr_list[0], (size_t)resolv->h_length);
UNLOCK();
dns_insert(addr, domain);
UNLOCK();
return 0;
}
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: log.c,v 1.13 2001-08-29 03:59:12 rjkaes Exp $
/* $Id: log.c,v 1.14 2001-09-04 16:50:22 rjkaes Exp $
*
* Logs the various messages which tinyproxy produces to either a log file or
* the syslog daemon. Not much to it...
@@ -93,7 +93,7 @@ void log_message(short int level, char *fmt, ...)
vsyslog(level, fmt, args);
# else
vsnprintf(str, STRING_LENGTH, fmt, args);
syslog(level, str);
syslog(level, "%s", str);
# endif
} else {
#endif
+5 -5
View File
@@ -1,4 +1,4 @@
/* $Id: reqs.c,v 1.17 2001-08-28 04:32:14 rjkaes Exp $
/* $Id: reqs.c,v 1.19 2001-09-04 18:22:00 rjkaes Exp $
*
* This is where all the work in tinyproxy is actually done. Incoming
* connections have a new thread created for them. The thread then
@@ -326,7 +326,7 @@ static int compare_header(char *line)
char *ptr;
int ret;
if ((ptr = xstrstr(line, ":", strlen(line), FALSE)) == NULL)
if ((ptr = strstr(line, ":")) == NULL)
return -1;
if ((buffer = malloc(ptr - line + 1)) == NULL)
@@ -424,9 +424,6 @@ static int process_client_headers(struct conn_s *connptr)
if (connptr->output_message)
continue;
if (is_anonymous_enabled() && compare_header(header) < 0)
continue;
/*
* Don't send certain headers.
*/
@@ -438,6 +435,9 @@ static int process_client_headers(struct conn_s *connptr)
if (i != (sizeof(skipheaders) / sizeof(char *)))
continue;
if (is_anonymous_enabled() && compare_header(header) < 0)
continue;
if (content_length == -1
&& strncasecmp(header, "content-length", 14) == 0) {
char *content_ptr = strchr(header, ':') + 1;
+13 -5
View File
@@ -1,4 +1,4 @@
/* $Id: ternary.c,v 1.5 2001-05-23 17:59:53 rjkaes Exp $
/* $Id: ternary.c,v 1.7 2001-09-04 17:53:41 rjkaes Exp $
*
* This module creates a Ternary Search Tree which can store both string
* keys, and arbitrary data for each key. It works similar to a hash, and
@@ -29,6 +29,7 @@
# include <sys/types.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -294,7 +295,8 @@ int ternary_destroy(TERNARY tno, void (*freeptr)(void *))
* TE_TOOFULL tree is full, so no new elements can be added.
* Exceptions: none
*/
int ternary_insert(TERNARY tno, const char *s, void *data)
int ternary_insert_replace(TERNARY tno, const char *s, void *data,
short int replace)
{
int cur; /* index of current tree */
Ttree *tree; /* pointer to tree structure */
@@ -314,7 +316,13 @@ int ternary_insert(TERNARY tno, const char *s, void *data)
while ((pp = *p)) {
if ((d = *s - pp->splitchar) == 0) {
if (*s++ == 0) {
return TE_EXISTS;
if (!replace)
return TE_EXISTS;
else {
free(pp->eqkid);
pp->eqkid = (Tnode *)data;
return TE_NONE;
}
}
p = &(pp->eqkid);
} else if (d < 0)
@@ -379,9 +387,9 @@ int ternary_search(TERNARY tno, const char *s, void **data)
p = trees[cur]->tree_root;
while (p) {
if (*s < p->splitchar)
if (toupper(*s) < toupper(p->splitchar))
p = p->lokid;
else if (*s == p->splitchar) {
else if (toupper(*s) == toupper(p->splitchar)) {
if (*s++ == 0) {
if (data)
*data = (void *)p->eqkid;
+6 -2
View File
@@ -1,4 +1,4 @@
/* $Id: ternary.h,v 1.2 2000-09-26 04:59:20 rjkaes Exp $
/* $Id: ternary.h,v 1.3 2001-08-30 16:52:09 rjkaes Exp $
*
* See 'ternary.c' for a detailed description.
*
@@ -58,7 +58,11 @@ extern char te_errbuf[256];
extern TERNARY ternary_new(void);
extern int ternary_destroy(TERNARY tno, void (*freeptr)(void *));
extern int ternary_insert(TERNARY tno, const char *s, void *data);
#define ternary_insert(x, y, z) ternary_insert_replace(x, y, z, 0)
#define ternary_replace(x, y, z) ternary_insert_replace(x, y, z, 1)
extern int ternary_insert_replace(TERNARY tno, const char *s, void *data,
short int replace);
extern int ternary_search(TERNARY tno, const char *s, void **data);
#endif
+1 -29
View File
@@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.7 2001-08-28 04:33:54 rjkaes Exp $
/* $Id: utils.c,v 1.8 2001-08-30 16:52:56 rjkaes Exp $
*
* Misc. routines which are used by the various functions to handle strings
* and memory allocation and pretty much anything else we can think of. Also,
@@ -30,34 +30,6 @@
#include "sock.h"
#include "utils.h"
/*
* Find the start of the needle in the haystack. Limits the search to less
* than "length" characters. Returns NULL if the needle is not found.
*/
char *xstrstr(char *haystack, char *needle, size_t length,
bool_t case_sensitive)
{
unsigned int i;
/* Used to specify which function to use... need the decl. */
int (*fn) (const char *s1, const char *s2, size_t n);
if (case_sensitive)
fn = strncmp;
else
fn = strncasecmp;
if (strlen(needle) > length)
return NULL;
for (i = 0; i <= length - strlen(needle); i++) {
if ((*fn) (haystack + i, needle, strlen(needle)) == 0)
return (haystack + i);
}
return NULL;
}
/*
* Display an error to the client.
*/
+1 -4
View File
@@ -1,4 +1,4 @@
/* $Id: utils.h,v 1.5 2001-08-27 03:45:34 rjkaes Exp $
/* $Id: utils.h,v 1.6 2001-08-30 16:52:56 rjkaes Exp $
*
* See 'utils.h' for a detailed description.
*
@@ -21,9 +21,6 @@
#include "tinyproxy.h"
extern char *xstrstr(char *haystack, char *needle, size_t length,
bool_t case_sensitive);
extern int httperr(struct conn_s *connptr, int err, const char *msg);
extern void makedaemon(void);