Fix warnings for functions marked __attribute((warn_unused_result)).
This commit is contained in:
parent
7b949262c4
commit
214060ef20
5 changed files with 32 additions and 13 deletions
|
@ -669,7 +669,11 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
|
|||
/* Add the message authentication code */
|
||||
|
||||
if(digest_active(n->outdigest)) {
|
||||
digest_create(n->outdigest, &inpkt->seqno, inpkt->len, (char *)&inpkt->seqno + inpkt->len);
|
||||
if(!digest_create(n->outdigest, &inpkt->seqno, inpkt->len, (char *)&inpkt->seqno + inpkt->len)) {
|
||||
logger(DEBUG_TRAFFIC, LOG_ERR, "Error while encrypting packet to %s (%s)", n->name, n->hostname);
|
||||
goto end;
|
||||
}
|
||||
|
||||
inpkt->len += digest_length(n->outdigest);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,10 +54,16 @@ static bool prf_xor(int nid, const char *secret, size_t secretlen, char *seed, s
|
|||
|
||||
while(outlen > 0) {
|
||||
/* Inner HMAC */
|
||||
digest_create(digest, data, len + seedlen, data);
|
||||
if(!digest_create(digest, data, len + seedlen, data)) {
|
||||
digest_close(digest);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Outer HMAC */
|
||||
digest_create(digest, data, len + seedlen, hash);
|
||||
if(!digest_create(digest, data, len + seedlen, hash)) {
|
||||
digest_close(digest);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* XOR the results of the outer HMAC into the out buffer */
|
||||
for(int i = 0; i < len && i < outlen; i++)
|
||||
|
|
|
@ -273,7 +273,8 @@ bool send_metakey(connection_t *c) {
|
|||
|
||||
key[0] &= 0x7F;
|
||||
|
||||
cipher_set_key_from_rsa(c->outcipher, key, len, true);
|
||||
if(!cipher_set_key_from_rsa(c->outcipher, key, len, true))
|
||||
return false;
|
||||
|
||||
if(debug_level >= DEBUG_SCARY_THINGS) {
|
||||
bin2hex(key, hexkey, len);
|
||||
|
@ -403,11 +404,10 @@ bool challenge_h(connection_t *c, const char *request) {
|
|||
return false;
|
||||
}
|
||||
|
||||
c->allow_request = CHAL_REPLY;
|
||||
|
||||
/* Calculate the hash from the challenge we received */
|
||||
|
||||
digest_create(c->indigest, buffer, len, digest);
|
||||
if(!digest_create(c->indigest, buffer, len, digest))
|
||||
return false;
|
||||
|
||||
/* Convert the hash to a hexadecimal formatted string */
|
||||
|
||||
|
@ -415,6 +415,8 @@ bool challenge_h(connection_t *c, const char *request) {
|
|||
|
||||
/* Send the reply */
|
||||
|
||||
c->allow_request = CHAL_REPLY;
|
||||
|
||||
return send_request(c, "%d %s", CHAL_REPLY, buffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -273,8 +273,10 @@ bool send_ans_key(node_t *to) {
|
|||
abort();
|
||||
|
||||
randomize(key, keylen);
|
||||
cipher_set_key(to->incipher, key, false);
|
||||
digest_set_key(to->indigest, key, keylen);
|
||||
if(!cipher_set_key(to->incipher, key, false))
|
||||
abort();
|
||||
if(!digest_set_key(to->indigest, key, keylen))
|
||||
abort();
|
||||
|
||||
bin2hex(key, key, keylen);
|
||||
|
||||
|
@ -418,8 +420,10 @@ bool ans_key_h(connection_t *c, const char *request) {
|
|||
|
||||
/* Update our copy of the origin's packet key */
|
||||
|
||||
cipher_set_key(from->outcipher, key, true);
|
||||
digest_set_key(from->outdigest, key, keylen);
|
||||
if(!cipher_set_key(from->outcipher, key, true))
|
||||
return false;
|
||||
if(!digest_set_key(from->outdigest, key, keylen))
|
||||
return false;
|
||||
|
||||
from->status.validkey = true;
|
||||
from->sent_seqno = 0;
|
||||
|
|
|
@ -98,7 +98,9 @@ static bool send_record_priv_datagram(sptps_t *s, uint8_t type, const char *data
|
|||
|
||||
if(s->outstate) {
|
||||
// If first handshake has finished, encrypt and HMAC
|
||||
cipher_set_counter(s->outcipher, &seqno, sizeof seqno);
|
||||
if(!cipher_set_counter(s->outcipher, &seqno, sizeof seqno))
|
||||
return false;
|
||||
|
||||
if(!cipher_counter_xor(s->outcipher, buffer + 6, len + 1UL, buffer + 6))
|
||||
return false;
|
||||
|
||||
|
@ -490,7 +492,8 @@ static bool sptps_receive_data_datagram(sptps_t *s, const char *data, size_t len
|
|||
|
||||
// Decrypt.
|
||||
memcpy(&seqno, buffer + 2, 4);
|
||||
cipher_set_counter(s->incipher, &seqno, sizeof seqno);
|
||||
if(!cipher_set_counter(s->incipher, &seqno, sizeof seqno))
|
||||
return false;
|
||||
if(!cipher_counter_xor(s->incipher, buffer + 6, len - 4, buffer + 6))
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue