[tor-commits] [obfsproxy/master] Fixed stupid bug.

nickm at torproject.org nickm at torproject.org
Sun May 29 01:33:38 UTC 2011


commit 35abc50a3646d6165ba7f3e9ac0efd218bb0e162
Author: George Kadianakis <desnacked at gmail.com>
Date:   Wed May 25 04:51:51 2011 +0200

    Fixed stupid bug.
---
 src/protocols/obfs2.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/protocols/obfs2.c b/src/protocols/obfs2.c
index 6221bb2..4159691 100644
--- a/src/protocols/obfs2.c
+++ b/src/protocols/obfs2.c
@@ -290,13 +290,20 @@ obfs2_send(void *s,
   obfs2_state_t *state = s;
 
   if (state->send_crypto) {
+    /* First of all, send any data that we've been waiting to send. */
+    if (state->pending_data_to_send) {
+      crypt_and_transmit(state->send_crypto, state->pending_data_to_send, dest);
+      evbuffer_free(state->pending_data_to_send);
+      state->pending_data_to_send = NULL;
+    }
     /* Our crypto is set up; just relay the bytes */
     return crypt_and_transmit(state->send_crypto, source, dest);
   } else {
     /* Our crypto isn't set up yet, we'll have to queue the data */
     if (evbuffer_get_length(source)) {
       if (! state->pending_data_to_send) {
-        state->pending_data_to_send = evbuffer_new();
+        if ((state->pending_data_to_send = evbuffer_new()) == NULL)
+          return -1;
       }
       evbuffer_add_buffer(state->pending_data_to_send, source);
     }
@@ -387,13 +394,6 @@ obfs2_recv(void *s, struct evbuffer *source,
     if (plength > OBFUSCATE_MAX_PADDING)
       return -1;
 
-    /* Send any data that we've been waiting to send */
-    if (state->pending_data_to_send) {
-      crypt_and_transmit(state->send_crypto, state->pending_data_to_send, dest);
-      evbuffer_free(state->pending_data_to_send);
-      state->pending_data_to_send = NULL;
-    }
-
     /* Now we're waiting for plength bytes of padding */
     state->padding_left_to_read = plength;
     state->state = ST_WAIT_FOR_PADDING;





More information about the tor-commits mailing list