[tor-commits] [stegotorus/master] Don't use bzero.
zwol at torproject.org
zwol at torproject.org
Fri Jul 20 23:17:07 UTC 2012
commit f5a51ee02171da3ba825ff9ab8e1be1a30a96c22
Author: Zack Weinberg <zackw at cmu.edu>
Date: Mon Apr 30 16:32:46 2012 -0700
Don't use bzero.
---
src/steg/b64cookies.cc | 10 ++++------
src/steg/cookies.cc | 4 ++--
src/steg/http.cc | 6 +++---
src/steg/payloads.cc | 4 ++--
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/steg/b64cookies.cc b/src/steg/b64cookies.cc
index 2efa76a..4d85a8b 100644
--- a/src/steg/b64cookies.cc
+++ b/src/steg/b64cookies.cc
@@ -190,8 +190,8 @@ void desanitize_b64(char* input, int len) {
// srand(time(NULL));
-// bzero(data2, sizeof(data2));
-// bzero(outbuf, sizeof(outbuf));
+// memset(data2, 0, sizeof(data2));
+// memset(outbuf, 0, sizeof(outbuf));
// base64::encoder E;
// E.encode(data, strlen(data), data2);
@@ -208,7 +208,7 @@ void desanitize_b64(char* input, int len) {
// cookielen = gen_b64_cookie_field((char*) outbuf, (char*) data2, strlen(data2));
// printf("cookie=%s\n", outbuf);
-// bzero(data2, sizeof(data2));
+// memset(data2, 0, sizeof(data2));
// cookielen = unwrap_b64_cookie((char*) outbuf, (char*) data2, strlen(outbuf));
@@ -219,10 +219,8 @@ void desanitize_b64(char* input, int len) {
// data2[strlen(data2)] = '\n';
-// bzero(outbuf, 200);
+// memset(outbuf, 0, sizeof(outbuf));
-
-
// base64::decoder D;
// D.decode(data2, strlen(data2), outbuf);
// printf("%s\n", outbuf);
diff --git a/src/steg/cookies.cc b/src/steg/cookies.cc
index a945397..3a7abf5 100644
--- a/src/steg/cookies.cc
+++ b/src/steg/cookies.cc
@@ -216,10 +216,10 @@ int main () {
for (i=0; i < 1000000; i++) {
int cookielen = rand()%50 + 5;
- bzero(outbuf, sizeof(outbuf));
+ memset(outbuf, 0, sizeof(outbuf));
int len = gen_cookie_field(outbuf, cookielen, data, sizeof(data));
// printf("len = %d cookie = %s %d\n", len, outbuf, cookielen);
- bzero(data2, sizeof(data2));
+ memset(data2, 0, sizeof(data2));
int len2 = unwrap_cookie(outbuf, data2, cookielen);
// printf("unwrapped datalen = %d data = %s\n", len, data2);
diff --git a/src/steg/http.cc b/src/steg/http.cc
index c413cdc..cfeaf93 100644
--- a/src/steg/http.cc
+++ b/src/steg/http.cc
@@ -307,7 +307,7 @@ http_client_cookie_transmit (http_steg_t *s, struct evbuffer *source,
if (s->peer_dnsname[0] == '\0')
lookup_peer_name_from_ip(conn->peername, s->peer_dnsname);
- bzero(data2, sbuflen*4);
+ memset(data2, 0, sbuflen*4);
E.encode((char*) data, sbuflen, (char*) data2);
E.encode_end(data2+strlen((char*) data2));
@@ -668,12 +668,12 @@ http_server_receive(http_steg_t *s, conn_t *conn, struct evbuffer *dest, struct
log_abort(conn, "cookie too big: %lu (max %lu)",
(unsigned long)(pend - p), (unsigned long)MAX_COOKIE_SIZE);
- bzero(outbuf, sizeof(outbuf));
+ memset(outbuf, 0, sizeof(outbuf));
int cookielen = unwrap_b64_cookie((char*) p, (char*) outbuf, pend - p);
desanitize_b64(outbuf, cookielen);
outbuf[cookielen] = '\n';
- bzero(outbuf2, sizeof(outbuf2));
+ memset(outbuf2, 0, sizeof(outbuf2));
base64::decoder D;
sofar = D.decode(outbuf, cookielen+1, outbuf2);
diff --git a/src/steg/payloads.cc b/src/steg/payloads.cc
index 7116e36..3af80d4 100644
--- a/src/steg/payloads.cc
+++ b/src/steg/payloads.cc
@@ -199,7 +199,7 @@ void load_payloads(payloads& pl, const char* fname)
exit(1);
}
- bzero(pl.payload_hdrs, sizeof(pl.payload_hdrs));
+ memset(pl.payload_hdrs, 0, sizeof(pl.payload_hdrs));
pl.payload_count = 0;
while (pl.payload_count < MAX_PAYLOADS) {
@@ -1598,7 +1598,7 @@ void testCapacityJS () {
/*****
int main() {
char buf[HTTP_MSG_BUF_SIZE];
- bzero(buf, sizeof(buf));
+ memset(buf, 0, sizeof(buf));
// test for TYPE_HTTP_REQUEST
// load_payloads("../../traces/client.out");
// int len = find_client_payload(buf, 10000, TYPE_HTTP_REQUEST);
More information about the tor-commits
mailing list