summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-04-20 18:08:35 +0300
committeraunsane <aunsane@gmail.com>2018-04-20 18:08:35 +0300
commit38197ead1ac8e551b09726b74557a6f980d15237 (patch)
treef44fe0a2e9f7654d56c6318447324654fb8d2162
parent12ddedba78c4b28914271e9ccb64ddf4d46c1aaf (diff)
Tox: toxcore updated to v0.2.2
-rw-r--r--protocols/Tox/libtox/docs/CHANGELOG.md19
-rw-r--r--protocols/Tox/libtox/src/toxcore/network.c23
-rw-r--r--protocols/Tox/libtox/src/toxcore/network.h4
-rw-r--r--protocols/Tox/libtox/src/toxcore/onion.c24
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox.api.h2
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox.h2
6 files changed, 62 insertions, 12 deletions
diff --git a/protocols/Tox/libtox/docs/CHANGELOG.md b/protocols/Tox/libtox/docs/CHANGELOG.md
index de54cddd11..b659e7a6d7 100644
--- a/protocols/Tox/libtox/docs/CHANGELOG.md
+++ b/protocols/Tox/libtox/docs/CHANGELOG.md
@@ -1,9 +1,28 @@
+## v0.2.2
+
+### Merged PRs:
+
+- [#872](https://github.com/TokTok/c-toxcore/issues/872) Restrict packet kinds that can be sent through onion path.
+- [#864](https://github.com/TokTok/c-toxcore/issues/864) CMake warn if libconfig not found
+- [#863](https://github.com/TokTok/c-toxcore/issues/863) Remove broken and unmaintained scripts.
+- [#859](https://github.com/TokTok/c-toxcore/issues/859) Add clarifying comment to cryptpacket_received function.
+- [#857](https://github.com/TokTok/c-toxcore/issues/857) Avoid the use of rand() in tests.
+- [#846](https://github.com/TokTok/c-toxcore/issues/846) Disallow stderr logger by default.
+- [#845](https://github.com/TokTok/c-toxcore/issues/845) Fix coveralls reporting.
+- [#844](https://github.com/TokTok/c-toxcore/issues/844) Add COVERAGE cmake flag for clang.
+- [#825](https://github.com/TokTok/c-toxcore/issues/825) Add default stderr logger for logging to nullptr.
+- [#824](https://github.com/TokTok/c-toxcore/issues/824) Simplify sendpacket function, deduplicate some logic.
+- [#809](https://github.com/TokTok/c-toxcore/issues/809) Remove the use of the 'hh' format specifier.
+- [#801](https://github.com/TokTok/c-toxcore/issues/801) Add logging to the onion_test.
+- [#797](https://github.com/TokTok/c-toxcore/issues/797) Move struct DHT_Friend into DHT.c.
+
## v0.2.1
### Merged PRs:
+- [#839](https://github.com/TokTok/c-toxcore/pull/839) Update changelog for 0.2.1
- [#837](https://github.com/TokTok/c-toxcore/pull/837) Update version to 0.2.1.
- [#833](https://github.com/TokTok/c-toxcore/pull/833) Add missing tox_nospam_size() function
- [#832](https://github.com/TokTok/c-toxcore/pull/832) Don't set RTP_LARGE_FRAME on rtp audio packets
diff --git a/protocols/Tox/libtox/src/toxcore/network.c b/protocols/Tox/libtox/src/toxcore/network.c
index 6e19a58610..984071d4e3 100644
--- a/protocols/Tox/libtox/src/toxcore/network.c
+++ b/protocols/Tox/libtox/src/toxcore/network.c
@@ -377,7 +377,7 @@ static void loglogdata(Logger *log, const char *message, const uint8_t *buffer,
if (res < 0) { /* Windows doesn't necessarily know %zu */
int error = net_error();
- char *strerror = net_new_strerror(error);
+ const char *strerror = net_new_strerror(error);
LOGGER_TRACE(log, "[%2u] %s %3u%c %s:%u (%u: %s) | %04x%04x",
buffer[0], message, (buflen < 999 ? buflen : 999), 'E',
ip_ntoa(&ip_port.ip, ip_str, sizeof(ip_str)), net_ntohs(ip_port.port), error,
@@ -504,7 +504,7 @@ static int receivepacket(Logger *log, Socket sock, IP_Port *ip_port, uint8_t *da
int error = net_error();
if (fail_or_len < 0 && error != TOX_EWOULDBLOCK) {
- char *strerror = net_new_strerror(error);
+ const char *strerror = net_new_strerror(error);
LOGGER_ERROR(log, "Unexpected error reading from socket: %u, %s", error, strerror);
net_kill_strerror(strerror);
}
@@ -688,7 +688,7 @@ Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint1
/* Check for socket error. */
if (!sock_valid(temp->sock)) {
int neterror = net_error();
- char *strerror = net_new_strerror(neterror);
+ const char *strerror = net_new_strerror(neterror);
LOGGER_ERROR(log, "Failed to get a socket?! %d, %s", neterror, strerror);
net_kill_strerror(strerror);
free(temp);
@@ -779,7 +779,7 @@ Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint1
int res = setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (const char *)&mreq, sizeof(mreq));
int neterror = net_error();
- char *strerror = net_new_strerror(neterror);
+ const char *strerror = net_new_strerror(neterror);
LOGGER_DEBUG(log, res < 0 ? "Failed to activate local multicast membership. (%d, %s)" :
"Local multicast group FF02::1 joined successfully", neterror, strerror);
net_kill_strerror(strerror);
@@ -840,7 +840,7 @@ Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint1
char ip_str[IP_NTOA_LEN];
int neterror = net_error();
- char *strerror = net_new_strerror(neterror);
+ const char *strerror = net_new_strerror(neterror);
LOGGER_ERROR(log, "Failed to bind socket: %d, %s IP: %s port_from: %u port_to: %u", neterror, strerror,
ip_ntoa(&ip, ip_str, sizeof(ip_str)), port_from, port_to);
net_kill_strerror(strerror);
@@ -1544,10 +1544,17 @@ int net_error(void)
#endif
}
-char *net_new_strerror(int error)
+const char *net_new_strerror(int error)
{
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
char *str = nullptr;
+ // Windows API is weird. The 5th function arg is of char* type, but we
+ // have to pass char** so that it could assign new memory block to our
+ // pointer, so we have to cast our char** to char* for the compilation
+ // not to fail (otherwise it would fail to find a variant of this function
+ // accepting char** as the 5th arg) and Windows inside casts it back
+ // to char** to do the assignment. So no, this cast you see here, although
+ // it looks weird, is not a mistake.
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr,
error, 0, (char *)&str, 0, nullptr);
return str;
@@ -1556,9 +1563,9 @@ char *net_new_strerror(int error)
#endif
}
-void net_kill_strerror(char *strerror)
+void net_kill_strerror(const char *strerror)
{
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- LocalFree(strerror);
+ LocalFree((char *)strerror);
#endif
}
diff --git a/protocols/Tox/libtox/src/toxcore/network.h b/protocols/Tox/libtox/src/toxcore/network.h
index 193a02faf8..10ddef0217 100644
--- a/protocols/Tox/libtox/src/toxcore/network.h
+++ b/protocols/Tox/libtox/src/toxcore/network.h
@@ -424,13 +424,13 @@ int net_error(void);
* return pointer to a NULL-terminated string describing the error code on
* success. The returned string must be freed using net_kill_strerror().
*/
-char *net_new_strerror(int error);
+const char *net_new_strerror(int error);
/* Frees the string returned by net_new_strerror().
* It's valid to pass NULL as the argument, the function does nothing in this
* case.
*/
-void net_kill_strerror(char *strerror);
+void net_kill_strerror(const char *strerror);
/* Initialize networking.
* bind to ip and port.
diff --git a/protocols/Tox/libtox/src/toxcore/onion.c b/protocols/Tox/libtox/src/toxcore/onion.c
index 48cc4d768c..740c25ce10 100644
--- a/protocols/Tox/libtox/src/toxcore/onion.c
+++ b/protocols/Tox/libtox/src/toxcore/onion.c
@@ -471,6 +471,15 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui
return 1;
}
+ if (len <= SIZE_IPPORT) {
+ return 1;
+ }
+
+ if (plain[SIZE_IPPORT] != NET_PACKET_ANNOUNCE_REQUEST &&
+ plain[SIZE_IPPORT] != NET_PACKET_ONION_DATA_REQUEST) {
+ return 1;
+ }
+
IP_Port send_to;
if (ipport_unpack(&send_to, plain, len, 0) == -1) {
@@ -514,6 +523,11 @@ static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, ui
return 1;
}
+ if (packet[1 + RETURN_3] != NET_PACKET_ANNOUNCE_RESPONSE &&
+ packet[1 + RETURN_3] != NET_PACKET_ONION_DATA_RESPONSE) {
+ return 1;
+ }
+
change_symmetric_key(onion);
uint8_t plain[SIZE_IPPORT + RETURN_2];
@@ -555,6 +569,11 @@ static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, ui
return 1;
}
+ if (packet[1 + RETURN_2] != NET_PACKET_ANNOUNCE_RESPONSE &&
+ packet[1 + RETURN_2] != NET_PACKET_ONION_DATA_RESPONSE) {
+ return 1;
+ }
+
change_symmetric_key(onion);
uint8_t plain[SIZE_IPPORT + RETURN_1];
@@ -596,6 +615,11 @@ static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, ui
return 1;
}
+ if (packet[1 + RETURN_1] != NET_PACKET_ANNOUNCE_RESPONSE &&
+ packet[1 + RETURN_1] != NET_PACKET_ONION_DATA_RESPONSE) {
+ return 1;
+ }
+
change_symmetric_key(onion);
uint8_t plain[SIZE_IPPORT];
diff --git a/protocols/Tox/libtox/src/toxcore/tox.api.h b/protocols/Tox/libtox/src/toxcore/tox.api.h
index d6148414be..1c3b112115 100644
--- a/protocols/Tox/libtox/src/toxcore/tox.api.h
+++ b/protocols/Tox/libtox/src/toxcore/tox.api.h
@@ -179,7 +179,7 @@ const VERSION_MINOR = 2;
* The patch or revision number. Incremented when bugfixes are applied without
* changing any functionality or API or ABI.
*/
-const VERSION_PATCH = 1;
+const VERSION_PATCH = 2;
/**
* A macro to check at preprocessing time whether the client code is compatible
diff --git a/protocols/Tox/libtox/src/toxcore/tox.h b/protocols/Tox/libtox/src/toxcore/tox.h
index c65f1e2566..d58340950d 100644
--- a/protocols/Tox/libtox/src/toxcore/tox.h
+++ b/protocols/Tox/libtox/src/toxcore/tox.h
@@ -180,7 +180,7 @@ uint32_t tox_version_minor(void);
* The patch or revision number. Incremented when bugfixes are applied without
* changing any functionality or API or ABI.
*/
-#define TOX_VERSION_PATCH 1
+#define TOX_VERSION_PATCH 2
uint32_t tox_version_patch(void);