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
Benjamin J. Thompson
Tor
Commits
c5269a59
Commit
c5269a59
authored
11 years ago
by
George Kadianakis
Committed by
Nick Mathewson
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Test ExtORPort cookie initialization when file writing is broken.
parent
94db4554
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/common/util.c
+3
-3
3 additions, 3 deletions
src/common/util.c
src/common/util.h
+3
-2
3 additions, 2 deletions
src/common/util.h
src/test/test_extorport.c
+21
-0
21 additions, 0 deletions
src/test/test_extorport.c
with
27 additions
and
5 deletions
src/common/util.c
+
3
−
3
View file @
c5269a59
...
...
@@ -2216,9 +2216,9 @@ write_bytes_to_file_impl(const char *fname, const char *str, size_t len,
/** As write_str_to_file, but does not assume a NUL-terminated
* string. Instead, we write <b>len</b> bytes, starting at <b>str</b>. */
int
write_bytes_to_file
(
const
char
*
fname
,
const
char
*
str
,
size_t
len
,
int
bin
)
MOCK_IMPL
(
int
,
write_bytes_to_file
,
(
const
char
*
fname
,
const
char
*
str
,
size_t
len
,
int
bin
)
)
{
return
write_bytes_to_file_impl
(
fname
,
str
,
len
,
OPEN_FLAGS_REPLACE
|
(
bin
?
O_BINARY
:
O_TEXT
));
...
...
This diff is collapsed.
Click to expand it.
src/common/util.h
+
3
−
2
View file @
c5269a59
...
...
@@ -355,8 +355,9 @@ FILE *fdopen_file(open_file_t *file_data);
int
finish_writing_to_file
(
open_file_t
*
file_data
);
int
abort_writing_to_file
(
open_file_t
*
file_data
);
int
write_str_to_file
(
const
char
*
fname
,
const
char
*
str
,
int
bin
);
int
write_bytes_to_file
(
const
char
*
fname
,
const
char
*
str
,
size_t
len
,
int
bin
);
MOCK_DECL
(
int
,
write_bytes_to_file
,(
const
char
*
fname
,
const
char
*
str
,
size_t
len
,
int
bin
));
/** An ad-hoc type to hold a string of characters and a count; used by
* write_chunks_to_file. */
typedef
struct
sized_chunk_t
{
...
...
This diff is collapsed.
Click to expand it.
src/test/test_extorport.c
+
21
−
0
View file @
c5269a59
...
...
@@ -149,6 +149,18 @@ test_ext_or_write_command(void *arg)
UNMOCK
(
connection_write_to_buf_impl_
);
}
static
int
write_bytes_to_file_fail
(
const
char
*
fname
,
const
char
*
str
,
size_t
len
,
int
bin
)
{
(
void
)
fname
;
(
void
)
str
;
(
void
)
len
;
(
void
)
bin
;
return
-
1
;
}
static
void
test_ext_or_init_auth
(
void
*
arg
)
{
...
...
@@ -177,6 +189,14 @@ test_ext_or_init_auth(void *arg)
tt_str_op
(
cp
,
==
,
fn
);
tor_free
(
cp
);
/* Test the initialization function with a broken
write_bytes_to_file(). See if the problem is handled properly. */
MOCK
(
write_bytes_to_file
,
write_bytes_to_file_fail
);
tt_int_op
(
-
1
,
==
,
init_ext_or_cookie_authentication
(
1
));
tt_int_op
(
ext_or_auth_cookie_is_set
,
==
,
0
);
UNMOCK
(
write_bytes_to_file
);
/* Now do the actual initialization. */
tt_int_op
(
0
,
==
,
init_ext_or_cookie_authentication
(
1
));
tt_int_op
(
ext_or_auth_cookie_is_set
,
==
,
1
);
cp
=
read_file_to_str
(
fn
,
RFTS_BIN
,
&
st
);
...
...
@@ -193,6 +213,7 @@ test_ext_or_init_auth(void *arg)
done:
tor_free
(
cp
);
ext_orport_free_all
();
}
static
void
...
...
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