commit 2fec32a099a2f6da98ba2b35b3b897a537724b31
parent 15282222da53e504a37d93895d5cd8fc0bb4dc29
Author: Frederic Cambus <fred@statdns.com>
Date: Thu, 22 Oct 2020 22:57:20 +0200
Check strndup() return value and error out if allocation fails.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/location.c b/src/location.c
@@ -4,7 +4,7 @@
* https://www.telize.com
*
* Created: 2013-08-15
- * Last Updated: 2020-06-09
+ * Last Updated: 2020-10-21
*
* Telize is released under the BSD 2-Clause license.
* See LICENSE file for details.
@@ -129,6 +129,11 @@ request_location(struct http_request *req)
if (entry_data.has_data) {
tz_len = entry_data.data_size;
tz = strndup(entry_data.utf8_string, tz_len);
+ if (!tz) {
+ kore_buf_free(json);
+ http_response(req, HTTP_STATUS_INTERNAL_ERROR, NULL, 0);
+ return (KORE_RESULT_OK);
+ }
kore_buf_init(&buf, tz_len);
kore_buf_append(&buf, tz, tz_len);