Commit 37d16c3c authored by Sebastian Hahn's avatar Sebastian Hahn
Browse files

Reserve enough space for rend_service_port_config_t

In #14803, Damian noticed that his Tor sometimes segfaults. Roger noted
that his valgrind gave an invalid write of size one here. Whenever we
use FLEXIBLE_ARRAY_MEMBER, we have to make sure to actually malloc a
thing that's large enough.

Fixes bug #14803, not in any released version of Tor.
parent b101f4e9
...@@ -314,7 +314,7 @@ static rend_service_port_config_t * ...@@ -314,7 +314,7 @@ static rend_service_port_config_t *
rend_service_port_config_new(const char *socket_path) rend_service_port_config_new(const char *socket_path)
{ {
if (!socket_path) if (!socket_path)
return tor_malloc_zero(sizeof(rend_service_port_config_t)); return tor_malloc_zero(sizeof(rend_service_port_config_t) + 1);
const size_t pathlen = strlen(socket_path) + 1; const size_t pathlen = strlen(socket_path) + 1;
rend_service_port_config_t *conf = rend_service_port_config_t *conf =
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment