Fix LP#1883169 by using growing_buffer
authorkenstir <kenstir@gmail.com>
Sun, 14 Jun 2020 01:43:57 +0000 (21:43 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 17 Sep 2021 17:41:50 +0000 (13:41 -0400)
commit5a41d66a9215a7da7f0a2dd2b3dd23610ba6d01a
treed819ece938dd5a030a1b05c2b429f887bdf6880c
parenta03b08905c7fb7d891b8abdd3f200b6fba231b08
Fix LP#1883169 by using growing_buffer

When presented with an error message that has more than 32 characters
that need to be escaped, the gateway fails to reserve enough space in
the memory allocation it uses to build the JSON message.  Instead of
guessing at how much space will be needed, and failing for some
messages, this commit uses growing_buffer to build the JSON.
growing_buffer is limited to 10Mb, so while large messages could be
generated, they won't cause an OOM on the server side.

Signed-off-by: Ken Cox <kenstir@gmail.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
src/gateway/osrf_json_gateway.c