summaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-03-02 22:29:04 +0000
committerRoger Dingledine <arma@torproject.org>2008-03-02 22:29:04 +0000
commit5bf0a01011f1505dbe9ff3d03343001b9ff0cb0a (patch)
tree0fab6130bbee93469b087210ea611b2c5659314b /src/or/buffers.c
parentcf3e1b13095cbfcbda3f56f65a88a3ace3e8ad6d (diff)
downloadtor-5bf0a01011f1505dbe9ff3d03343001b9ff0cb0a.tar.gz
tor-5bf0a01011f1505dbe9ff3d03343001b9ff0cb0a.zip
forward-port r13799 and the 0.2.0.21-rc changelog
svn:r13808
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 7b54dd3968..d91482d852 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -635,13 +635,13 @@ read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof)
check();
if (r < 0)
return r; /* Error */
- else if ((size_t)r < readlen) { /* eof, block, or no more to read. */
- tor_assert(r+total_read < INT_MAX);
- return (int)(r + total_read);
- }
+ tor_assert(total_read+r < INT_MAX);
total_read += r;
+ if ((size_t)r < readlen) { /* eof, block, or no more to read. */
+ break;
+ }
}
- return r;
+ return (int)total_read;
}
/** As read_to_buf, but reads from a TLS connection, and returns a TLS
@@ -689,11 +689,12 @@ read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf)
check();
if (r < 0)
return r; /* Error */
- else if ((size_t)r < readlen) /* eof, block, or no more to read. */
- return r;
- total_read += r;
+ tor_assert(total_read+r < INT_MAX);
+ total_read += r;
+ if ((size_t)r < readlen) /* eof, block, or no more to read. */
+ break;
}
- return r;
+ return (int)total_read;
}
/** Helper for flush_buf(): try to write <b>sz</b> bytes from chunk