Teor found these. This is for part of #16582.
len = crypto_read_tagged_contents_from_file(filename, "ed25519v1-secret",
tag_out, seckey_out->seckey,
sizeof(seckey_out->seckey));
- if (len != sizeof(seckey_out->seckey))
- return -1;
+ if (len == sizeof(seckey_out->seckey)) {
+ return 0;
+ } else if (len >= 0) {
+ errno = EINVAL;
+ }
- return 0;
+ return -1;
}
/**
len = crypto_read_tagged_contents_from_file(filename, "ed25519v1-public",
tag_out, pubkey_out->pubkey,
sizeof(pubkey_out->pubkey));
- if (len != sizeof(pubkey_out->pubkey))
- return -1;
+ if (len == sizeof(pubkey_out->pubkey)) {
+ return 0;
+ } else if (len >= 0) {
+ errno = EINVAL;
+ }
- return 0;
+ return -1;
}
/** Release all storage held for <b>kp</b>. */
size_t numread = 0;
ssize_t result;
- if (count > SIZE_T_CEILING || count > SSIZE_MAX)
+ if (count > SIZE_T_CEILING || count > SSIZE_MAX) {
+ errno = EINVAL;
return -1;
+ }
while (numread != count) {
if (isSocket)
char *string = NULL;
size_t string_max = 0;
- if (max_bytes_to_read+1 >= SIZE_T_CEILING)
+ if (max_bytes_to_read+1 >= SIZE_T_CEILING) {
+ errno = EINVAL;
return NULL;
+ }
do {
/* XXXX This "add 1K" approach is a little goofy; if we care about
if ((uint64_t)(statbuf.st_size)+1 >= SIZE_T_CEILING) {
close(fd);
+ errno = EINVAL;
return NULL;
}
r = 0;
goto done;
}
- if (strcmp(tag, ENC_KEY_TAG))
+ if (strcmp(tag, ENC_KEY_TAG)) {
+ saved_errno = EINVAL;
goto done;
+ }
while (1) {
ssize_t pwlen =
tor_getpass("Enter pasphrase for master key:", pwbuf, sizeof(pwbuf));
- if (pwlen < 0)
+ if (pwlen < 0) {
+ saved_errno = EINVAL;
goto done;
+ }
const int r = crypto_unpwbox(&secret, &secret_len,
encrypted_key, encrypted_len,