Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mike Perry
Tor
Commits
b7633e2e
Commit
b7633e2e
authored
21 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Try to find out early if buffers get trashed or double-freed.
svn:r1225
parent
3e452fed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/or/buffers.c
+15
-3
15 additions, 3 deletions
src/or/buffers.c
src/or/connection.c
+2
-2
2 additions, 2 deletions
src/or/connection.c
src/or/or.h
+2
-0
2 additions, 0 deletions
src/or/or.h
with
19 additions
and
5 deletions
src/or/buffers.c
+
15
−
3
View file @
b7633e2e
...
...
@@ -6,7 +6,9 @@
#include
"or.h"
#define BUFFER_MAGIC 0xB0FFF312u
struct
buf_t
{
uint32_t
magic
;
/* for debugging */
char
*
mem
;
size_t
len
;
size_t
datalen
;
...
...
@@ -118,6 +120,7 @@ int find_on_inbuf(char *string, int string_len, buf_t *buf) {
buf_t
*
buf_new_with_capacity
(
size_t
size
)
{
buf_t
*
buf
;
buf
=
(
buf_t
*
)
tor_malloc
(
sizeof
(
buf_t
));
buf
->
magic
=
BUFFER_MAGIC
;
buf
->
mem
=
(
char
*
)
tor_malloc
(
size
);
buf
->
len
=
size
;
buf
->
datalen
=
0
;
...
...
@@ -153,9 +156,10 @@ const char *_buf_peek_raw_buffer(const buf_t *buf)
}
void
buf_free
(
buf_t
*
buf
)
{
assert
(
buf
&&
buf
->
mem
);
free
(
buf
->
mem
);
free
(
buf
);
assert_buf_ok
(
buf
);
buf
->
magic
=
0xDEADBEEF
;
tor_free
(
buf
->
mem
);
tor_free
(
buf
);
}
/* read from socket s, writing onto end of buf.
...
...
@@ -576,6 +580,14 @@ int fetch_from_buf_socks(buf_t *buf, socks_request_t *req) {
}
}
void
assert_buf_ok
(
buf_t
*
buf
)
{
assert
(
buf
);
assert
(
buf
->
magic
==
BUFFER_MAGIC
);
assert
(
buf
->
mem
);
assert
(
buf
->
datalen
<=
buf
->
len
);
}
/*
Local Variables:
mode:c
...
...
This diff is collapsed.
Click to expand it.
src/or/connection.c
+
2
−
2
View file @
b7633e2e
...
...
@@ -866,8 +866,8 @@ void assert_connection_ok(connection_t *conn, time_t now)
/* buffers */
if
(
!
connection_is_listener
(
conn
))
{
assert
(
conn
->
inbuf
);
assert
(
conn
->
outbuf
);
assert
_buf_ok
(
conn
->
inbuf
);
assert
_buf_ok
(
conn
->
outbuf
);
}
assert
(
!
now
||
conn
->
timestamp_lastread
<=
now
);
...
...
This diff is collapsed.
Click to expand it.
src/or/or.h
+
2
−
0
View file @
b7633e2e
...
...
@@ -572,6 +572,8 @@ int fetch_from_buf_http(buf_t *buf,
char
**
body_out
,
int
max_bodylen
);
int
fetch_from_buf_socks
(
buf_t
*
buf
,
socks_request_t
*
req
);
void
assert_buf_ok
(
buf_t
*
buf
);
/********************************* circuit.c ***************************/
void
circuit_add
(
circuit_t
*
circ
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment