Fixed bug with TCP.

Don't increment nonce if packet was discarded instead of being sent.
This commit is contained in:
irungentoo 2014-07-15 12:35:57 -04:00
parent 59821d6a5e
commit 078d60ab92
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 10 additions and 10 deletions

View File

@ -155,16 +155,16 @@ static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, const
if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
return -1; return -1;
increment_nonce(con->sent_nonce);
len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL);
if ((unsigned int)len == sizeof(packet))
return 1;
if (len <= 0) if (len <= 0)
return 0; return 0;
increment_nonce(con->sent_nonce);
if ((unsigned int)len == sizeof(packet))
return 1;
memcpy(con->last_packet, packet, length); memcpy(con->last_packet, packet, length);
con->last_packet_length = sizeof(packet); con->last_packet_length = sizeof(packet);
con->last_packet_sent = len; con->last_packet_sent = len;

View File

@ -335,16 +335,16 @@ static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con, const
if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
return -1; return -1;
increment_nonce(con->sent_nonce);
len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL);
if ((unsigned int)len == sizeof(packet))
return 1;
if (len <= 0) if (len <= 0)
return 0; return 0;
increment_nonce(con->sent_nonce);
if ((unsigned int)len == sizeof(packet))
return 1;
memcpy(con->last_packet, packet, length); memcpy(con->last_packet, packet, length);
con->last_packet_length = sizeof(packet); con->last_packet_length = sizeof(packet);
con->last_packet_sent = len; con->last_packet_sent = len;