Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Goulet
Tor
Commits
9abd7b8f
Commit
9abd7b8f
authored
May 16, 2016
by
Nick Mathewson
🐻
Browse files
Windows lacks truncate(3).
Fix the new crypto tests, which used truncate(3).
parent
5dbb0bda
Changes
2
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
9abd7b8f
...
...
@@ -432,6 +432,7 @@ AC_CHECK_FUNCS(
strtoull \
sysconf \
sysctl \
truncate \
uname \
usleep \
vasprintf \
...
...
src/test/test_crypto.c
View file @
9abd7b8f
...
...
@@ -1322,6 +1322,29 @@ test_crypto_pk_base64(void *arg)
tor_free
(
encoded
);
}
#ifdef HAVE_TRUNCATE
#define do_truncate truncate
#else
static
int
do_truncate
(
const
char
*
fname
,
size_t
len
)
{
struct
stat
st
;
char
*
bytes
;
bytes
=
read_file_to_str
(
fname
,
RFTS_BIN
,
&
st
);
if
(
!
bytes
)
return
-
1
;
/* This cast isn't so great, but it should be safe given the actual files
* and lengths we're using. */
if
(
st
.
st_size
<
(
off_t
)
len
)
len
=
MIN
(
len
,
(
size_t
)
st
.
st_size
);
int
r
=
write_bytes_to_file
(
fname
,
bytes
,
len
,
1
);
tor_free
(
bytes
);
return
r
;
}
#endif
/** Sanity check for crypto pk digests */
static
void
test_crypto_digests
(
void
*
arg
)
...
...
@@ -2664,8 +2687,8 @@ test_crypto_ed25519_storage(void *arg)
tor_free
(
tag
);
/* whitebox test: truncated keys. */
tt_int_op
(
0
,
==
,
truncate
(
fname_1
,
40
));
tt_int_op
(
0
,
==
,
truncate
(
fname_2
,
40
));
tt_int_op
(
0
,
==
,
do_
truncate
(
fname_1
,
40
));
tt_int_op
(
0
,
==
,
do_
truncate
(
fname_2
,
40
));
tt_int_op
(
-
1
,
OP_EQ
,
ed25519_pubkey_read_from_file
(
&
pub
,
&
tag
,
fname_2
));
tt_ptr_op
(
tag
,
OP_EQ
,
NULL
);
tor_free
(
tag
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment