summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2002-04-26 16:43:20 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2002-04-26 16:43:20 +0000
commit0e7182533ce53592139e8ea35fab48b4ddaa43ae (patch)
tree1d0b2c63d949a2cf1653bd76e22b3ba9dc925399
parent6992c74bba22981acd866d4b3521b0e31ad15fae (diff)
downloadtinyproxy-0e7182533ce53592139e8ea35fab48b4ddaa43ae.tar.gz
tinyproxy-0e7182533ce53592139e8ea35fab48b4ddaa43ae.zip
Need to check the return value of hashmap_first() since it could be
negative.
Diffstat (limited to '')
-rw-r--r--ChangeLog6
-rw-r--r--src/reqs.c50
2 files changed, 32 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 7bafb66..5e13517 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-04-26 Robert James Kaes <rjkaes@flarenet.com>
+
+ * src/reqs.c (process_client_headers):
+ (process_server_headers): Test the return value of hashmap_first()
+ since the hashmap could be empty (returning a -1 via hashmap_first.)
+
2002-04-25 Robert James Kaes <rjkaes@flarenet.com>
* src/reqs.c (remove_connection_headers): Handle both the
diff --git a/src/reqs.c b/src/reqs.c
index 18bc675..f5cf0a6 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1,4 +1,4 @@
-/* $Id: reqs.c,v 1.67 2002-04-25 19:20:56 rjkaes Exp $
+/* $Id: reqs.c,v 1.68 2002-04-26 16:43:20 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
@@ -769,18 +769,19 @@ process_client_headers(struct conn_s *connptr)
/*
* Output all the remaining headers to the remote machine.
*/
- for (iter = hashmap_first(hashofheaders);
- !hashmap_is_end(hashofheaders, iter);
- ++iter) {
- hashmap_return_entry(hashofheaders,
- iter,
- &data,
- (void**)&header);
-
- if (!is_anonymous_enabled() || anonymous_search(data) <= 0) {
- write_message(connptr->server_fd,
- "%s: %s\r\n",
- data, header);
+ iter = hashmap_first(hashofheaders);
+ if (iter >= 0) {
+ for ( ; !hashmap_is_end(hashofheaders, iter); ++iter) {
+ hashmap_return_entry(hashofheaders,
+ iter,
+ &data,
+ (void**)&header);
+
+ if (!is_anonymous_enabled() || anonymous_search(data) <= 0) {
+ write_message(connptr->server_fd,
+ "%s: %s\r\n",
+ data, header);
+ }
}
}
@@ -879,17 +880,18 @@ process_server_headers(struct conn_s *connptr)
/*
* Okay, output all the remaining headers to the client.
*/
- for (iter = hashmap_first(hashofheaders);
- !hashmap_is_end(hashofheaders, iter);
- ++iter) {
- hashmap_return_entry(hashofheaders,
- iter,
- &data,
- (void **)&header);
-
- write_message(connptr->client_fd,
- "%s: %s\r\n",
- data, header);
+ iter = hashmap_first(hashofheaders);
+ if (iter >= 0) {
+ for ( ; !hashmap_is_end(hashofheaders, iter); ++iter) {
+ hashmap_return_entry(hashofheaders,
+ iter,
+ &data,
+ (void **)&header);
+
+ write_message(connptr->client_fd,
+ "%s: %s\r\n",
+ data, header);
+ }
}
hashmap_delete(hashofheaders);