Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dea98a3b08 | ||
|
|
7c1548cfce | ||
|
|
ed253766ea | ||
|
|
772c2849e8 | ||
|
|
25537d30d3 | ||
|
|
625cecf492 | ||
|
|
86f38819c0 | ||
|
|
7b2892be76 | ||
|
|
ad99033ae4 | ||
|
|
757d341d96 | ||
|
|
b92e2fc457 | ||
|
|
a30eb425e3 | ||
|
|
bc8c3ff399 | ||
|
|
90ee7e01ca | ||
|
|
dde4e9adcc | ||
|
|
99488cbd5e | ||
|
|
fffdc76681 | ||
|
|
d2f2750a37 | ||
|
|
ddb002d57e | ||
|
|
270af08171 | ||
|
|
3d9a64d54e | ||
|
|
9f0c8f18fb | ||
|
|
e61424a7bf | ||
|
|
4680546c65 | ||
|
|
84ff99013a |
No files matched your search
+18
@@ -0,0 +1,18 @@
|
|||||||
|
COPYING
|
||||||
|
INSTALL
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
NEWS
|
||||||
|
aclocal.m4
|
||||||
|
config.cache
|
||||||
|
config.h
|
||||||
|
config.h.in
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
configure
|
||||||
|
depcomp
|
||||||
|
install-sh
|
||||||
|
libtool
|
||||||
|
missing
|
||||||
|
mkinstalldirs
|
||||||
|
stamp-h1
|
||||||
@@ -1,7 +1,22 @@
|
|||||||
|
2001-11-03 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/buffer.c (remove_from_buffer): This function is never
|
||||||
|
called with an empty buffer, so removed some inaccurate code which
|
||||||
|
would have removed an invalid line from the buffer if it was
|
||||||
|
empty. What was I thinking when I wrote that? Good thing is was
|
||||||
|
never called.
|
||||||
|
(add_to_buffer): Add a bit of a sanity check to make sure the
|
||||||
|
buffer structure hasn't been messed up some how.
|
||||||
|
|
||||||
|
2001-11-02 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/acl.c (insert_acl): Tightened the check regarding whether an
|
||||||
|
ACL is a string or a numeric address.
|
||||||
|
|
||||||
2001-10-25 Robert James Kaes <rjkaes@flarenet.com>
|
2001-10-25 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
* Moved all the system header included into the tinyproxy.h header
|
* Moved all the system header included into the tinyproxy.h header
|
||||||
and changed all the other files to include it. The should
|
and changed all the other files to include it. This should
|
||||||
centralise the header dependency issue into one file.
|
centralise the header dependency issue into one file.
|
||||||
|
|
||||||
* src/conns.c: Brought back the conns.{c,h} files which contain
|
* src/conns.c: Brought back the conns.{c,h} files which contain
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
EXTRA_DIST = configure acconfig.h aclocal.m4 acinclude.m4 TODO
|
EXTRA_DIST = TODO
|
||||||
SUBDIRS = src doc
|
SUBDIRS = src doc
|
||||||
@@ -1,28 +1,35 @@
|
|||||||
Thursday, October 25, 2001
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
This version (1.4.3pre7) should be the last release before I make a
|
NEWS
|
||||||
full 1.4.3 release of tinyproxy. So, assuming no one reports any
|
====
|
||||||
problems with 1.4.3pre7 it will become 1.4.3 with no changes.
|
|
||||||
|
|
||||||
For more information as what has been worked on, look at the
|
There are a few problems with this version of tinyproxy, but I'm hoping
|
||||||
ChangeLog. As you can tell, I don't keep this "NEWS" file very up to
|
the benefits outweigh the negative. For some reason tinyproxy is not
|
||||||
date. All the real logging of information happens in the ChangeLog
|
able to handle requests to *.x10.com sites. (As someone mentioned: "maybe
|
||||||
file since I update it as I work on the code. Here on the other hand,
|
this is a feature?" :) There also seem to be a few other random sites
|
||||||
I have to remember what I've done. Not near as seamless. (Maybe I
|
where tinyproxy is not communicating with the server correctly. If you
|
||||||
should get somebody else to write the NEWS file...)
|
find any such sites, let me know so I can add it to the list of domains
|
||||||
|
where tinyproxy is failing. I'll need this information for the regression
|
||||||
|
tests I plan on performing on the next release.
|
||||||
|
|
||||||
-- Robert
|
As for the next release (1.5.0), I will not be adding new features.
|
||||||
|
tinyproxy doesn't currently conform correctly to either the HTTP/1.0
|
||||||
|
or the HTTP/1.1 standards. The goal of the 1.5 release therefore is
|
||||||
|
to achieve standards compliance with at least HTTP/1.0. If you have
|
||||||
|
looked at the tinyproxy code you will have noticed that all the real
|
||||||
|
work of the proxy is performed in the reqs.c file. Therefore, other
|
||||||
|
than bug fixes in the other files, only reqs.c should be changed in
|
||||||
|
the 1.5.0 release. Basically, I'm hoping to just gut and replace the
|
||||||
|
reqs.c file with a standards compliant version and release a new version.
|
||||||
|
|
||||||
|
Depending on my schedule I should have the new version ready for
|
||||||
|
pre-testing sometime next week. If you have any suggestions for improving
|
||||||
|
tinyproxy please let me know, but I will not be incorporating them until
|
||||||
|
1.6 (which _hopefully_ should come out fairly quickly after 1.5 has
|
||||||
|
stabilised.)
|
||||||
|
|
||||||
Tuesday, September 4, 2001
|
"Thank you" go out to all who have helped find bugs in the 1.4.3
|
||||||
--------------------------
|
candidates. You know who you are, and if you don't look in the ChangeLog
|
||||||
|
for your name. :)
|
||||||
|
|
||||||
I finally fixed a problem with the anonymous header code. The searches
|
Robert James Kaes
|
||||||
are now all case insensitive. This fixes a problem where the spelling
|
November 21, 2001
|
||||||
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.
|
|
||||||
|
|
||||||
-- Robert
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
Tinyproxy wouldn't be possible in its current form without the help of
|
|
||||||
the following people. Thanks a lot, guys (sorted in no particular
|
|
||||||
order). Note that in the case of entries listed under 'numerous others',
|
|
||||||
only the first person to report it is listed.
|
|
||||||
|
|
||||||
|
|
||||||
Steven Young - Wrote version 1.0 - 1.1
|
|
||||||
Robert James Kaes - Wrote versions from 1.2 to 1.3 and
|
|
||||||
autoconf enabled the source tree and
|
|
||||||
well just look at the ChangeLog for all
|
|
||||||
the rest. :)
|
|
||||||
Albert Ragnarsson - Made an RPM out of the 1.0d .tar.gz archive.
|
|
||||||
Alan W Black - Misc. bug reports and fixes.
|
|
||||||
Ed Boraas - Various suggestions, helped beta test 1.0d.
|
|
||||||
Abhijit Menon-Sen - Beta tested 1.1, numerous bugs fixed
|
|
||||||
and features improved. Also helped
|
|
||||||
establish world peace and eliminate
|
|
||||||
hunger and poverty. Generally
|
|
||||||
credited with the singlehanded
|
|
||||||
abolition of all crime and dishonesty.
|
|
||||||
Jay Kominek - Made the 1.1 DEB.
|
|
||||||
Eran Tromer - Provided webspace at attacca.com.
|
|
||||||
Bruno Viaris - Found and provided initial fix for
|
|
||||||
bug in the clientreq() routine when
|
|
||||||
dealing with broken requests from clients.
|
|
||||||
Alexander Loehr - Found and provided fix for a bug in
|
|
||||||
the listen_sock routine.
|
|
||||||
Bob Grabau - Added additional logging of URLs to
|
|
||||||
incoming connections.
|
|
||||||
Mitsuru Yoshida - Made the FreeBSD port
|
|
||||||
Ian Holsman - Suggested the selective listening option
|
|
||||||
Peter Meerwald - Portability suggests and improvements
|
|
||||||
Shaun Johnson - Fixed a problem with compiling with
|
|
||||||
syslog enabled on a SunOS box. Should
|
|
||||||
help other systems too.
|
|
||||||
Timothy E. Newsome - SOCKS firewall enabled tinyproxy
|
|
||||||
George Talusan - Bug testing
|
|
||||||
Chris Lightfoot - Provided patches to give tinyproxy adns
|
|
||||||
support.
|
|
||||||
Michael Pearson - Reported connptr bug with patch.
|
|
||||||
Raja Subramanian - Reported fd leak bug, with patch.
|
|
||||||
J.D. Bronson - Helped make version 1.4.0 release ready
|
|
||||||
Hans-Georg Bork - Fixed a problem with the thread_main()
|
|
||||||
function and added the LOG_CONN log level.
|
|
||||||
numerous others - Reported null requests bug.
|
|
||||||
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
dnl $Id: configure.in,v 1.33 2001-10-25 05:13:46 rjkaes Exp $
|
dnl $Id: configure.in,v 1.35 2001-11-21 19:35:51 rjkaes Exp $
|
||||||
|
|
||||||
dnl Devlopers, please strive to achieve this order:
|
dnl Devlopers, please strive to achieve this order:
|
||||||
dnl
|
dnl
|
||||||
@@ -19,7 +19,7 @@ AC_INIT()
|
|||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
|
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE(tinyproxy,1.4.3pre7)
|
AM_INIT_AUTOMAKE(tinyproxy,1.4.3)
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
@@ -142,7 +142,7 @@ dnl avoid -lnsl checks, if we already have the functions which are
|
|||||||
dnl usually in libnsl
|
dnl usually in libnsl
|
||||||
|
|
||||||
unset ac_cv_func_yp_get_default_domain
|
unset ac_cv_func_yp_get_default_domain
|
||||||
AC_CHECK_FUNC(yp_get_default_domain, [ tinyproxy_no_nsl_checks=yes ], [ ])
|
AC_CHECK_FUNC(yp_get_default_domain, [ tinyproxy_no_nsl_checks=yes ])
|
||||||
unset ac_cv_func_yp_get_default_domain
|
unset ac_cv_func_yp_get_default_domain
|
||||||
|
|
||||||
if test "$tinyproxy_no_nsl_checks" != "yes"; then
|
if test "$tinyproxy_no_nsl_checks" != "yes"; then
|
||||||
@@ -253,6 +253,7 @@ CFLAGS="-O2 $CFLAGS"
|
|||||||
if test "$enable_debug" = "yes" ; then
|
if test "$enable_debug" = "yes" ; then
|
||||||
dnl Add the warnings if we have the GCC compiler
|
dnl Add the warnings if we have the GCC compiler
|
||||||
if test "$ac_cv_prog_gcc" = "yes" ; then
|
if test "$ac_cv_prog_gcc" = "yes" ; then
|
||||||
|
CFLAGS="-pg -fprofile-arcs $CFLAGS"
|
||||||
CFLAGS="-Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes $CFLAGS"
|
CFLAGS="-Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes $CFLAGS"
|
||||||
CFLAGS="-Wmissing-prototypes -Wmissing-declarations $CFLAGS"
|
CFLAGS="-Wmissing-prototypes -Wmissing-declarations $CFLAGS"
|
||||||
CFLAGS="-Wpointer-arith -Waggregate-return -Wnested-externs $CFLAGS"
|
CFLAGS="-Wpointer-arith -Waggregate-return -Wnested-externs $CFLAGS"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
report.sh
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
.deps
|
||||||
|
.libs
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
grammar.c
|
||||||
|
grammar.h
|
||||||
|
scanner.c
|
||||||
|
tinyproxy
|
||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.6 2001-10-25 16:58:50 rjkaes Exp $
|
# $Id: Makefile.am,v 1.7 2001-11-05 15:24:01 rjkaes Exp $
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -46,3 +46,4 @@ EXTRA_tinyproxy_SOURCES = grammar.h
|
|||||||
|
|
||||||
scanner.c: scanner.l grammar.h
|
scanner.c: scanner.l grammar.h
|
||||||
$(LEX) $(AM_LFLAGS) $(LFLAGS) -i $< && mv $(LEX_OUTPUT_ROOT).c $@
|
$(LEX) $(AM_LFLAGS) $(LFLAGS) -i $< && mv $(LEX_OUTPUT_ROOT).c $@
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: acl.c,v 1.9 2001-10-25 17:27:39 rjkaes Exp $
|
/* $Id: acl.c,v 1.10 2001-11-03 06:08:37 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This system handles Access Control for use of this daemon. A list of
|
* This system handles Access Control for use of this daemon. A list of
|
||||||
* domains, or IP addresses (including IP blocks) are stored in a list
|
* domains, or IP addresses (including IP blocks) are stored in a list
|
||||||
@@ -77,8 +77,11 @@ int insert_acl(char *location, acl_access_t access_type)
|
|||||||
/*
|
/*
|
||||||
* First check to see if the location is a string or numeric.
|
* First check to see if the location is a string or numeric.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < strlen((char *)location); i++) {
|
for (i = 0; location[i] != '\0'; i++) {
|
||||||
if (isdigit((unsigned char)location[i]) != 0 && location[i] != '.') {
|
/*
|
||||||
|
* Numeric strings can not contain letters, so test on it.
|
||||||
|
*/
|
||||||
|
if (isalpha((unsigned char)location[i])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,9 +102,11 @@ int insert_acl(char *location, acl_access_t access_type)
|
|||||||
|
|
||||||
new_acl_ptr->acl_access = access_type;
|
new_acl_ptr->acl_access = access_type;
|
||||||
|
|
||||||
if (i != strlen(location)) {
|
if (location[i] == '\0') {
|
||||||
|
DEBUG2("ACL \"%s\" is a number.", location);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We did break early, so this a numeric location.
|
* We did not break early, so this a numeric location.
|
||||||
* Check for a netmask.
|
* Check for a netmask.
|
||||||
*/
|
*/
|
||||||
new_acl_ptr->type = ACL_NUMERIC;
|
new_acl_ptr->type = ACL_NUMERIC;
|
||||||
@@ -109,7 +114,7 @@ int insert_acl(char *location, acl_access_t access_type)
|
|||||||
if (nptr) {
|
if (nptr) {
|
||||||
*nptr++ = '\0';
|
*nptr++ = '\0';
|
||||||
|
|
||||||
new_acl_ptr->netmask = atoi(nptr);
|
new_acl_ptr->netmask = strtol(nptr, NULL, 10);
|
||||||
if (new_acl_ptr->netmask < 0 || new_acl_ptr->netmask > 32) {
|
if (new_acl_ptr->netmask < 0 || new_acl_ptr->netmask > 32) {
|
||||||
safefree(new_acl_ptr);
|
safefree(new_acl_ptr);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -118,6 +123,8 @@ int insert_acl(char *location, acl_access_t access_type)
|
|||||||
new_acl_ptr->netmask = 32;
|
new_acl_ptr->netmask = 32;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
DEBUG2("ACL \"%s\" is a string.", location);
|
||||||
|
|
||||||
new_acl_ptr->type = ACL_STRING;
|
new_acl_ptr->type = ACL_STRING;
|
||||||
new_acl_ptr->netmask = 32;
|
new_acl_ptr->netmask = 32;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: anonymous.c,v 1.7 2001-10-25 17:27:39 rjkaes Exp $
|
/* $Id: anonymous.c,v 1.8 2001-11-05 15:24:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Handles insertion and searches for headers which should be let through when
|
* Handles insertion and searches for headers which should be let through when
|
||||||
* the anonymous feature is turned on. The headers are stored in a Ternary
|
* the anonymous feature is turned on. The headers are stored in a Ternary
|
||||||
@@ -32,7 +32,7 @@ static TERNARY anonymous_tree = 0;
|
|||||||
*/
|
*/
|
||||||
static short int anonymous_is_enabled = 0;
|
static short int anonymous_is_enabled = 0;
|
||||||
|
|
||||||
short int is_anonymous_enabled(void)
|
inline short int is_anonymous_enabled(void)
|
||||||
{
|
{
|
||||||
return anonymous_is_enabled;
|
return anonymous_is_enabled;
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-57
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: buffer.c,v 1.14 2001-10-25 04:39:10 rjkaes Exp $
|
/* $Id: buffer.c,v 1.15 2001-11-05 15:23:05 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* The buffer used in each connection is a linked list of lines. As the lines
|
* The buffer used in each connection is a linked list of lines. As the lines
|
||||||
* are read in and written out the buffer expands and contracts. Basically,
|
* are read in and written out the buffer expands and contracts. Basically,
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#define BUFFER_HEAD(x) (((struct buffer_s *)(x))->head)
|
#define BUFFER_HEAD(x) (x)->head
|
||||||
#define BUFFER_TAIL(x) (((struct buffer_s *)(x))->tail)
|
#define BUFFER_TAIL(x) (x)->tail
|
||||||
|
|
||||||
struct bufline_s {
|
struct bufline_s {
|
||||||
unsigned char *string; /* the actual string of data */
|
unsigned char *string; /* the actual string of data */
|
||||||
@@ -37,31 +37,18 @@ struct bufline_s {
|
|||||||
size_t pos; /* start sending from this offset */
|
size_t pos; /* start sending from this offset */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct buffer_s {
|
|
||||||
struct bufline_s *head; /* top of the buffer */
|
|
||||||
struct bufline_s *tail; /* bottom of the buffer */
|
|
||||||
size_t size; /* total size of the buffer */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the size of the supplied buffer.
|
|
||||||
*/
|
|
||||||
size_t buffer_size(struct buffer_s *buffptr)
|
|
||||||
{
|
|
||||||
assert(buffptr != NULL);
|
|
||||||
|
|
||||||
return buffptr->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Take a string of data and a length and make a new line which can be added
|
* Take a string of data and a length and make a new line which can be added
|
||||||
* to the buffer
|
* to the buffer. We don't make a copy of the data, but simply copy the
|
||||||
|
* pointer into the structure. In other words, when you insert data into the
|
||||||
|
* buffer, the buffer becomes responsible for freeing it.
|
||||||
*/
|
*/
|
||||||
static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
||||||
{
|
{
|
||||||
struct bufline_s *newline;
|
struct bufline_s *newline;
|
||||||
|
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
assert(length > 0);
|
||||||
|
|
||||||
if (!(newline = safemalloc(sizeof(struct bufline_s))))
|
if (!(newline = safemalloc(sizeof(struct bufline_s))))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -69,6 +56,8 @@ static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
|||||||
newline->string = data;
|
newline->string = data;
|
||||||
newline->next = NULL;
|
newline->next = NULL;
|
||||||
newline->length = length;
|
newline->length = length;
|
||||||
|
|
||||||
|
/* Position our "read" pointer at the beginning of the data */
|
||||||
newline->pos = 0;
|
newline->pos = 0;
|
||||||
|
|
||||||
return newline;
|
return newline;
|
||||||
@@ -100,8 +89,13 @@ struct buffer_s *new_buffer(void)
|
|||||||
if (!(buffptr = safemalloc(sizeof(struct buffer_s))))
|
if (!(buffptr = safemalloc(sizeof(struct buffer_s))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buffptr->head = buffptr->tail = NULL;
|
/*
|
||||||
buffptr->size = 0;
|
* Since the buffer is initially empty, set the HEAD and TAIL
|
||||||
|
* pointers to NULL since they can't possibly point anywhere at the
|
||||||
|
* moment.
|
||||||
|
*/
|
||||||
|
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = NULL;
|
||||||
|
BUFFER_SIZE(buffptr) = 0;
|
||||||
|
|
||||||
return buffptr;
|
return buffptr;
|
||||||
}
|
}
|
||||||
@@ -120,8 +114,6 @@ void delete_buffer(struct buffer_s *buffptr)
|
|||||||
free_line(BUFFER_HEAD(buffptr));
|
free_line(BUFFER_HEAD(buffptr));
|
||||||
BUFFER_HEAD(buffptr) = next;
|
BUFFER_HEAD(buffptr) = next;
|
||||||
}
|
}
|
||||||
BUFFER_HEAD(buffptr) = NULL;
|
|
||||||
BUFFER_TAIL(buffptr) = NULL;
|
|
||||||
|
|
||||||
safefree(buffptr);
|
safefree(buffptr);
|
||||||
}
|
}
|
||||||
@@ -136,43 +128,46 @@ static int add_to_buffer(struct buffer_s *buffptr, unsigned char *data,
|
|||||||
|
|
||||||
assert(buffptr != NULL);
|
assert(buffptr != NULL);
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
assert(length > 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanity check here. A buffer with a non-NULL head pointer must
|
||||||
|
* have a size greater than zero, and vice-versa.
|
||||||
|
*/
|
||||||
|
if (BUFFER_HEAD(buffptr) == NULL)
|
||||||
|
assert(BUFFER_SIZE(buffptr) == 0);
|
||||||
|
else
|
||||||
|
assert(BUFFER_SIZE(buffptr) > 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a new line so we can add it to the buffer.
|
||||||
|
*/
|
||||||
if (!(newline = makenewline(data, length)))
|
if (!(newline = makenewline(data, length)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!BUFFER_HEAD(buffptr) && !BUFFER_TAIL(buffptr))
|
if (BUFFER_SIZE(buffptr) == 0)
|
||||||
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = newline;
|
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = newline;
|
||||||
else
|
else
|
||||||
BUFFER_TAIL(buffptr) = (BUFFER_TAIL(buffptr)->next = newline);
|
BUFFER_TAIL(buffptr) = (BUFFER_TAIL(buffptr)->next = newline);
|
||||||
|
|
||||||
buffptr->size += length;
|
BUFFER_SIZE(buffptr) += length;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shift a line off the top of the buffer (remove the line from the top of
|
* Remove the first line from the top of the buffer
|
||||||
* the buffer)
|
|
||||||
*/
|
*/
|
||||||
static struct bufline_s *remove_from_buffer(struct buffer_s *buffptr)
|
static struct bufline_s *remove_from_buffer(struct buffer_s *buffptr)
|
||||||
{
|
{
|
||||||
struct bufline_s *line;
|
struct bufline_s *line;
|
||||||
|
|
||||||
assert(buffptr != NULL);
|
assert(buffptr != NULL);
|
||||||
|
assert(BUFFER_HEAD(buffptr) != NULL);
|
||||||
if (!BUFFER_HEAD(buffptr) && !BUFFER_TAIL(buffptr)) {
|
|
||||||
line = BUFFER_HEAD(buffptr);
|
|
||||||
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = NULL;
|
|
||||||
buffptr->size = 0;
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
line = BUFFER_HEAD(buffptr);
|
line = BUFFER_HEAD(buffptr);
|
||||||
BUFFER_HEAD(buffptr) = line->next;
|
BUFFER_HEAD(buffptr) = line->next;
|
||||||
|
|
||||||
if (!BUFFER_HEAD(buffptr))
|
|
||||||
BUFFER_TAIL(buffptr) = NULL;
|
|
||||||
|
|
||||||
buffptr->size -= line->length;
|
buffptr->size -= line->length;
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
@@ -192,14 +187,14 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(buffptr != NULL);
|
assert(buffptr != NULL);
|
||||||
|
|
||||||
if (buffer_size(buffptr) >= READ_BUFFER_SIZE)
|
if (BUFFER_SIZE(buffptr) >= READ_BUFFER_SIZE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer = safemalloc(READ_BUFFER_SIZE);
|
buffer = safemalloc(READ_BUFFER_SIZE);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bytesin = read(fd, buffer, READ_BUFFER_SIZE - buffer_size(buffptr));
|
bytesin = read(fd, buffer, READ_BUFFER_SIZE - BUFFER_SIZE(buffptr));
|
||||||
|
|
||||||
if (bytesin > 0) {
|
if (bytesin > 0) {
|
||||||
newbuffer = saferealloc(buffer, bytesin);
|
newbuffer = saferealloc(buffer, bytesin);
|
||||||
@@ -214,26 +209,26 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bytesin;
|
return bytesin;
|
||||||
} else if (bytesin == 0) {
|
|
||||||
/* connection was closed by client */
|
|
||||||
safefree(buffer);
|
|
||||||
return -1;
|
|
||||||
} else {
|
} else {
|
||||||
switch (errno) {
|
safefree(buffer);
|
||||||
|
if (bytesin == 0) {
|
||||||
|
/* connection was closed by client */
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
switch (errno) {
|
||||||
#ifdef EWOULDBLOCK
|
#ifdef EWOULDBLOCK
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
#else
|
#else
|
||||||
# ifdef EAGAIN
|
# ifdef EAGAIN
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
case EINTR:
|
case EINTR:
|
||||||
safefree(buffer);
|
return 0;
|
||||||
return 0;
|
default:
|
||||||
default:
|
log_message(LOG_ERR, "readbuff: recv() error \"%s\" on file descriptor %d", strerror(errno), fd);
|
||||||
log_message(LOG_ERR, "readbuff: recv() error \"%s\" on file descriptor %d", strerror(errno), fd);
|
return -1;
|
||||||
safefree(buffer);
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,11 +245,13 @@ ssize_t writebuff(int fd, struct buffer_s *buffptr)
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(buffptr != NULL);
|
assert(buffptr != NULL);
|
||||||
|
|
||||||
line = BUFFER_HEAD(buffptr);
|
if (BUFFER_SIZE(buffptr) == 0)
|
||||||
|
|
||||||
if (buffer_size(buffptr) <= 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* Sanity check. It would be bad to be using a NULL pointer! */
|
||||||
|
assert(BUFFER_HEAD(buffptr) != NULL);
|
||||||
|
|
||||||
|
line = BUFFER_HEAD(buffptr);
|
||||||
bytessent = write(fd, line->string + line->pos, line->length - line->pos);
|
bytessent = write(fd, line->string + line->pos, line->length - line->pos);
|
||||||
|
|
||||||
if (bytessent >= 0) {
|
if (bytessent >= 0) {
|
||||||
|
|||||||
+16
-2
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: buffer.h,v 1.4 2001-05-27 02:23:08 rjkaes Exp $
|
/* $Id: buffer.h,v 1.5 2001-11-05 15:23:05 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'buffer.c' for a detailed description.
|
* See 'buffer.c' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -18,9 +18,23 @@
|
|||||||
#ifndef _TINYPROXY_BUFFER_H_
|
#ifndef _TINYPROXY_BUFFER_H_
|
||||||
#define _TINYPROXY_BUFFER_H_
|
#define _TINYPROXY_BUFFER_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure contains the total size of a buffer, plus pointers to the
|
||||||
|
* head and tail of the buffer.
|
||||||
|
*/
|
||||||
|
struct buffer_s {
|
||||||
|
struct bufline_s *head; /* top of the buffer */
|
||||||
|
struct bufline_s *tail; /* bottom of the buffer */
|
||||||
|
size_t size; /* total size of the buffer */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the size of a buffer (pass a pointer to a buffer_s structure.)
|
||||||
|
*/
|
||||||
|
#define BUFFER_SIZE(x) (x)->size
|
||||||
|
|
||||||
extern struct buffer_s *new_buffer(void);
|
extern struct buffer_s *new_buffer(void);
|
||||||
extern void delete_buffer(struct buffer_s *buffptr);
|
extern void delete_buffer(struct buffer_s *buffptr);
|
||||||
extern size_t buffer_size(struct buffer_s *buffptr);
|
|
||||||
|
|
||||||
extern ssize_t readbuff(int fd, struct buffer_s *buffptr);
|
extern ssize_t readbuff(int fd, struct buffer_s *buffptr);
|
||||||
extern ssize_t writebuff(int fd, struct buffer_s *buffptr);
|
extern ssize_t writebuff(int fd, struct buffer_s *buffptr);
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: conns.c,v 1.3 2001-10-25 16:58:09 rjkaes Exp $
|
/* $Id: conns.c,v 1.4 2001-11-21 01:00:08 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Create and free the connection structure. One day there could be
|
* Create and free the connection structure. One day there could be
|
||||||
* other connnection related tasks put here, but for now the header
|
* other connnection related tasks put here, but for now the header
|
||||||
@@ -37,6 +37,8 @@ void initialize_conn(struct conn_s *connptr)
|
|||||||
connptr->ssl = FALSE;
|
connptr->ssl = FALSE;
|
||||||
connptr->upstream = FALSE;
|
connptr->upstream = FALSE;
|
||||||
|
|
||||||
|
connptr->protocol.major = connptr->protocol.minor = 0;
|
||||||
|
|
||||||
update_stats(STAT_OPEN);
|
update_stats(STAT_OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: conns.h,v 1.3 2001-10-25 16:58:09 rjkaes Exp $
|
/* $Id: conns.h,v 1.4 2001-11-21 01:00:09 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'conns.c' for a detailed description.
|
* See 'conns.c' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -30,6 +30,10 @@ struct conn_s {
|
|||||||
bool_t ssl;
|
bool_t ssl;
|
||||||
bool_t upstream;
|
bool_t upstream;
|
||||||
bool_t send_message;
|
bool_t send_message;
|
||||||
|
struct {
|
||||||
|
unsigned short int major;
|
||||||
|
unsigned short int minor;
|
||||||
|
} protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+67
-10
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: reqs.c,v 1.35 2001-10-25 16:58:50 rjkaes Exp $
|
/* $Id: reqs.c,v 1.39 2001-11-21 19:19:46 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This is where all the work in tinyproxy is actually done. Incoming
|
* This is where all the work in tinyproxy is actually done. Incoming
|
||||||
* connections have a new thread created for them. The thread then
|
* connections have a new thread created for them. The thread then
|
||||||
@@ -368,6 +368,14 @@ static struct request_s *process_request(struct conn_s *connptr,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Break apart the protocol and update the connection structure.
|
||||||
|
*/
|
||||||
|
if (strncasecmp(request->protocol, "http", 4) == 0) {
|
||||||
|
memcpy(request->protocol, "HTTP", 4);
|
||||||
|
sscanf(request->protocol, "HTTP/%hu.%hu", &connptr->protocol.major, &connptr->protocol.minor);
|
||||||
|
}
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,6 +454,12 @@ static int add_xtinyproxy_header(struct conn_s *connptr)
|
|||||||
char xtinyproxy[32];
|
char xtinyproxy[32];
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't try to send if we have an invalid server handle.
|
||||||
|
*/
|
||||||
|
if (connptr->server_fd == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
length = snprintf(xtinyproxy, sizeof(xtinyproxy),
|
length = snprintf(xtinyproxy, sizeof(xtinyproxy),
|
||||||
"X-Tinyproxy: %s\r\n",
|
"X-Tinyproxy: %s\r\n",
|
||||||
getpeer_ip(connptr->client_fd, ipaddr));
|
getpeer_ip(connptr->client_fd, ipaddr));
|
||||||
@@ -466,10 +480,16 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
{
|
{
|
||||||
char *header;
|
char *header;
|
||||||
long content_length = -1;
|
long content_length = -1;
|
||||||
|
#if 0
|
||||||
|
short int sent_via_header = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
static char *skipheaders[] = {
|
static char *skipheaders[] = {
|
||||||
"proxy-connection",
|
"proxy-connection",
|
||||||
"host",
|
"host",
|
||||||
|
"keep-alive",
|
||||||
|
"proxy-authenticate",
|
||||||
|
"proxy-authorization",
|
||||||
"connection"
|
"connection"
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
@@ -480,6 +500,7 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
|
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
if (readline(connptr->client_fd, header, LINE_LENGTH) <= 0) {
|
if (readline(connptr->client_fd, header, LINE_LENGTH) <= 0) {
|
||||||
|
DEBUG2("Client (file descriptor %d) closed connection.", connptr->client_fd);
|
||||||
safefree(header);
|
safefree(header);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -499,6 +520,26 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
if (connptr->ssl && !connptr->upstream)
|
if (connptr->ssl && !connptr->upstream)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
* If we find a Via header we need to append our information
|
||||||
|
* to the end of it.
|
||||||
|
*/
|
||||||
|
if (strncasecmp(header, "via", 3) == 0) {
|
||||||
|
char hostname[128];
|
||||||
|
char via_header_buffer[256];
|
||||||
|
|
||||||
|
sent_via_header = 1;
|
||||||
|
|
||||||
|
gethostname(hostname, sizeof(hostname));
|
||||||
|
snprintf(via_header_buffer, sizeof(via_header_buffer), ", %hu.%hu %s (%s/%s)\r\n", connptr->protocol.major, connptr->protocol.minor, hostname, PACKAGE, VERSION);
|
||||||
|
|
||||||
|
trim(header, strlen(header));
|
||||||
|
|
||||||
|
strlcat(header, via_header_buffer, LINE_LENGTH);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't send certain headers.
|
* Don't send certain headers.
|
||||||
*/
|
*/
|
||||||
@@ -519,12 +560,27 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
content_length = atol(content_ptr);
|
content_length = atol(content_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
if ((connptr->server_fd != -1) && safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
||||||
safefree(header);
|
safefree(header);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (sent_via_header == 0) {
|
||||||
|
/*
|
||||||
|
* We're the first proxy so send the first Via header.
|
||||||
|
*/
|
||||||
|
char via_header_buffer[256];
|
||||||
|
char hostname[128];
|
||||||
|
|
||||||
|
gethostname(hostname, sizeof(hostname));
|
||||||
|
snprintf(via_header_buffer, sizeof(via_header_buffer), "Via: %hu.%hu %s (%s/%s)\r\n", connptr->protocol.major, connptr->protocol.minor, hostname, PACKAGE, VERSION);
|
||||||
|
|
||||||
|
safe_write(connptr->server_fd, via_header_buffer, strlen(via_header_buffer));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!connptr->send_message && (connptr->upstream || !connptr->ssl)) {
|
if (!connptr->send_message && (connptr->upstream || !connptr->ssl)) {
|
||||||
#ifdef XTINYPROXY_ENABLE
|
#ifdef XTINYPROXY_ENABLE
|
||||||
if (config.my_domain
|
if (config.my_domain
|
||||||
@@ -534,7 +590,7 @@ static int process_client_headers(struct conn_s *connptr)
|
|||||||
}
|
}
|
||||||
#endif /* XTINYPROXY */
|
#endif /* XTINYPROXY */
|
||||||
|
|
||||||
if (safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
if ((connptr->server_fd != -1) && safe_write(connptr->server_fd, header, strlen(header)) < 0) {
|
||||||
safefree(header);
|
safefree(header);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -565,6 +621,7 @@ static int process_server_headers(struct conn_s *connptr)
|
|||||||
|
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
if (readline(connptr->server_fd, header, LINE_LENGTH) <= 0) {
|
if (readline(connptr->server_fd, header, LINE_LENGTH) <= 0) {
|
||||||
|
DEBUG2("Server (file descriptor %d) closed connection.", connptr->server_fd);
|
||||||
safefree(header);
|
safefree(header);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -620,13 +677,13 @@ static void relay_connection(struct conn_s *connptr)
|
|||||||
tv.tv_sec = config.idletimeout - difftime(time(NULL), last_access);
|
tv.tv_sec = config.idletimeout - difftime(time(NULL), last_access);
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
if (buffer_size(connptr->sbuffer) > 0)
|
if (BUFFER_SIZE(connptr->sbuffer) > 0)
|
||||||
FD_SET(connptr->client_fd, &wset);
|
FD_SET(connptr->client_fd, &wset);
|
||||||
if (buffer_size(connptr->cbuffer) > 0)
|
if (BUFFER_SIZE(connptr->cbuffer) > 0)
|
||||||
FD_SET(connptr->server_fd, &wset);
|
FD_SET(connptr->server_fd, &wset);
|
||||||
if (buffer_size(connptr->sbuffer) < MAXBUFFSIZE)
|
if (BUFFER_SIZE(connptr->sbuffer) < MAXBUFFSIZE)
|
||||||
FD_SET(connptr->server_fd, &rset);
|
FD_SET(connptr->server_fd, &rset);
|
||||||
if (buffer_size(connptr->cbuffer) < MAXBUFFSIZE)
|
if (BUFFER_SIZE(connptr->cbuffer) < MAXBUFFSIZE)
|
||||||
FD_SET(connptr->client_fd, &rset);
|
FD_SET(connptr->client_fd, &rset);
|
||||||
|
|
||||||
ret = select(maxfd, &rset, &wset, NULL, &tv);
|
ret = select(maxfd, &rset, &wset, NULL, &tv);
|
||||||
@@ -672,7 +729,7 @@ static void relay_connection(struct conn_s *connptr)
|
|||||||
* remainder to the client and then exit.
|
* remainder to the client and then exit.
|
||||||
*/
|
*/
|
||||||
socket_blocking(connptr->client_fd);
|
socket_blocking(connptr->client_fd);
|
||||||
while (buffer_size(connptr->sbuffer) > 0) {
|
while (BUFFER_SIZE(connptr->sbuffer) > 0) {
|
||||||
if (writebuff(connptr->client_fd, connptr->sbuffer) < 0)
|
if (writebuff(connptr->client_fd, connptr->sbuffer) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -681,7 +738,7 @@ static void relay_connection(struct conn_s *connptr)
|
|||||||
* Try to send any remaining data to the server if we can.
|
* Try to send any remaining data to the server if we can.
|
||||||
*/
|
*/
|
||||||
socket_blocking(connptr->server_fd);
|
socket_blocking(connptr->server_fd);
|
||||||
while (buffer_size(connptr->cbuffer) > 0) {
|
while (BUFFER_SIZE(connptr->cbuffer) > 0) {
|
||||||
if (writebuff(connptr->client_fd, connptr->cbuffer) < 0)
|
if (writebuff(connptr->client_fd, connptr->cbuffer) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -797,7 +854,7 @@ void handle_connection(int fd)
|
|||||||
goto internal_proxy;
|
goto internal_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message(LOG_CONN, "Established a connection to the tunnel \"%s\" using file descriptor %d.", config.tunnel_name, connptr->server_fd);
|
log_message(LOG_INFO, "Established a connection to the tunnel \"%s\" using file descriptor %d.", config.tunnel_name, connptr->server_fd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I know GOTOs are evil, but duplicating the code is even
|
* I know GOTOs are evil, but duplicating the code is even
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ static struct keyword keywords[] = {
|
|||||||
|
|
||||||
#define MAX_REGEXP_LEN 1024
|
#define MAX_REGEXP_LEN 1024
|
||||||
|
|
||||||
unsigned int yylineno = 1;
|
|
||||||
char tiny_buf[MAX_REGEXP_LEN];
|
char tiny_buf[MAX_REGEXP_LEN];
|
||||||
char *tiny_str;
|
char *tiny_str;
|
||||||
|
|
||||||
|
|||||||
+10
-6
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: sock.c,v 1.14 2001-10-25 05:10:32 rjkaes Exp $
|
/* $Id: sock.c,v 1.15 2001-11-12 21:10:51 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Sockets are created and destroyed here. When a new connection comes in from
|
* Sockets are created and destroyed here. When a new connection comes in from
|
||||||
* a client, we need to copy the socket and the create a second socket to the
|
* a client, we need to copy the socket and the create a second socket to the
|
||||||
@@ -155,7 +155,7 @@ int listen_sock(uint16_t port, socklen_t *addrlen)
|
|||||||
char *getpeer_ip(int fd, char *ipaddr)
|
char *getpeer_ip(int fd, char *ipaddr)
|
||||||
{
|
{
|
||||||
struct sockaddr_in name;
|
struct sockaddr_in name;
|
||||||
size_t namelen = sizeof(name);
|
socklen_t namelen = sizeof(name);
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(ipaddr != NULL);
|
assert(ipaddr != NULL);
|
||||||
@@ -183,7 +183,7 @@ char *getpeer_ip(int fd, char *ipaddr)
|
|||||||
char *getpeer_string(int fd, char *string)
|
char *getpeer_string(int fd, char *string)
|
||||||
{
|
{
|
||||||
struct sockaddr_in name;
|
struct sockaddr_in name;
|
||||||
size_t namelen = sizeof(name);
|
socklen_t namelen = sizeof(name);
|
||||||
struct hostent *peername;
|
struct hostent *peername;
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
@@ -259,18 +259,22 @@ ssize_t readline(int fd, char *ptr, size_t maxlen)
|
|||||||
|
|
||||||
for (n = 1; n < maxlen; n++) {
|
for (n = 1; n < maxlen; n++) {
|
||||||
again:
|
again:
|
||||||
if ((rc = read(fd, &c, 1)) == 1) {
|
if ((rc = recv(fd, &c, 1, MSG_NOSIGNAL)) == 1) {
|
||||||
*ptr++ = c;
|
*ptr++ = c;
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
} else if (rc == 0) {
|
} else if (rc == 0) {
|
||||||
if (n == 1)
|
if (n == 1) {
|
||||||
|
DEBUG2("File_Desc: %d Closed.", fd);
|
||||||
return 0;
|
return 0;
|
||||||
else
|
} else
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
|
DEBUG2("File_Desc: %d \"%s\" (%d)", fd, strerror(errno), errno);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -35,21 +35,21 @@
|
|||||||
void *debugging_calloc(size_t nmemb, size_t size, const char *file, unsigned long line)
|
void *debugging_calloc(size_t nmemb, size_t size, const char *file, unsigned long line)
|
||||||
{
|
{
|
||||||
void *ptr = calloc(nmemb, size);
|
void *ptr = calloc(nmemb, size);
|
||||||
fprintf(stderr, "{calloc: %p:%u x %u} %s:%lu\n", ptr, nmemb, size, file, line);
|
fprintf(stderr, "{calloc: %p:%zu x %zu} %s:%lu\n", ptr, nmemb, size, file, line);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *debugging_malloc(size_t size, const char *file, unsigned long line)
|
void *debugging_malloc(size_t size, const char *file, unsigned long line)
|
||||||
{
|
{
|
||||||
void *ptr = malloc(size);
|
void *ptr = malloc(size);
|
||||||
fprintf(stderr, "{malloc: %p:%u} %s:%lu\n", ptr, size, file, line);
|
fprintf(stderr, "{malloc: %p:%zu} %s:%lu\n", ptr, size, file, line);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *debugging_realloc(void *ptr, size_t size, const char *file, unsigned long line)
|
void *debugging_realloc(void *ptr, size_t size, const char *file, unsigned long line)
|
||||||
{
|
{
|
||||||
void *newptr = realloc(ptr, size);
|
void *newptr = realloc(ptr, size);
|
||||||
fprintf(stderr, "{realloc: %p -> %p:%u} %s:%lu\n", ptr, newptr, size, file, line);
|
fprintf(stderr, "{realloc: %p -> %p:%zu} %s:%lu\n", ptr, newptr, size, file, line);
|
||||||
return newptr;
|
return newptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user