[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[or-cvs] more robust when only some of the socks info has arrived
- To: or-cvs@freehaven.net
- Subject: [or-cvs] more robust when only some of the socks info has arrived
- From: arma@seul.org (Roger Dingledine)
- Date: Sun, 22 Sep 2002 21:05:02 -0400 (EDT)
- Delivered-To: archiver@seul.org
- Delivered-To: or-cvs-outgoing@seul.org
- Delivered-To: or-cvs@seul.org
- Delivery-Date: Sun, 22 Sep 2002 21:05:03 -0400
- Reply-To: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.seul.org:/home/arma/work/onion/cvs/src/or
Modified Files:
connection_ap.c or.h
Log Message:
more robust when only some of the socks info has arrived
Index: connection_ap.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_ap.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- connection_ap.c 22 Sep 2002 11:09:07 -0000 1.13
+++ connection_ap.c 23 Sep 2002 01:04:59 -0000 1.14
@@ -5,7 +5,6 @@
#include "or.h"
extern int global_role; /* from main.c */
-static const char socks_userid[] = "anonymous";
int connection_ap_process_inbuf(connection_t *conn) {
@@ -34,8 +33,6 @@
int ap_handshake_process_socks(connection_t *conn) {
char c;
socks4_t socks4_info;
- static char destaddr[512]; /* XXX there's a race condition waiting to happen here */
- static int destlen=0;
assert(conn);
@@ -85,7 +82,9 @@
}
if(!conn->read_username) { /* the socks spec says we've got to read stuff until we get a null */
- while(conn->inbuf_datalen) {
+ for(;;) {
+ if(!conn->inbuf_datalen)
+ return 0; /* maybe next time */
if(connection_fetch_from_buf((char *)&c,1,conn) < 0)
return -1;
if(!c) {
@@ -98,19 +97,19 @@
if(!conn->dest_addr) { /* no dest_addr found yet */
- while(conn->inbuf_datalen) {
+ for(;;) {
+ if(!conn->inbuf_datalen)
+ return 0; /* maybe next time */
if(connection_fetch_from_buf((char *)&c,1,conn) < 0)
return -1;
- destaddr[destlen++] = c;
- if(destlen > 500) {
+ conn->dest_tmp[conn->dest_tmplen++] = c;
+ if(conn->dest_tmplen > 500) {
log(LOG_NOTICE,"ap_handshake_process_socks(): dest_addr too long!");
ap_handshake_socks_reply(conn, SOCKS4_REQUEST_REJECT);
- destlen = 0;
return -1;
}
if(!c) { /* we found the null; we're done */
- conn->dest_addr = strdup(destaddr);
- destlen = 0;
+ conn->dest_addr = strdup(conn->dest_tmp);
log(LOG_NOTICE,"ap_handshake_process_socks(): successfully read dest addr '%s'",
conn->dest_addr);
break;
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- or.h 22 Sep 2002 11:09:07 -0000 1.24
+++ or.h 23 Sep 2002 01:04:59 -0000 1.25
@@ -213,6 +213,9 @@
char *dest_addr;
uint16_t dest_port;
+
+ char dest_tmp[512];
+ int dest_tmplen;
/* used by OR, to keep state while connect()ing: Kludge. */