aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpgme-json.c
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2018-07-18 11:06:08 +0000
committerAndre Heinecke <[email protected]>2018-07-18 11:06:08 +0000
commit6d7b4382c3e12ba1dbbd0762dfa850c76750d838 (patch)
tree3122124527fe3cabc6808c2f36c86e7bbc45557e /src/gpgme-json.c
parentjson: Fix crash by ensuring response is never NULL (diff)
downloadgpgme-6d7b4382c3e12ba1dbbd0762dfa850c76750d838.tar.gz
gpgme-6d7b4382c3e12ba1dbbd0762dfa850c76750d838.zip
json: Ensure that native msging request is string
* src/gpgme-json.c (native_messaging_repl): Ensure that the request is NULL terminated. -- This avoids potential memory leaks and access to unmapped memory in case the request was not terminated. Other request functions use es_read_line which gurantees NULL termination.
Diffstat (limited to 'src/gpgme-json.c')
-rw-r--r--src/gpgme-json.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gpgme-json.c b/src/gpgme-json.c
index edd3d32e..74ca2b6e 100644
--- a/src/gpgme-json.c
+++ b/src/gpgme-json.c
@@ -3601,7 +3601,7 @@ native_messaging_repl (void)
}
/* Read request. */
- request = xtrymalloc (nrequest);
+ request = xtrymalloc (nrequest + 1);
if (!request)
{
err = gpg_error_from_syserror ();
@@ -3626,6 +3626,7 @@ native_messaging_repl (void)
}
else /* Process request */
{
+ request[n] = '\0'; /* Esnure that request has an end */
if (opt_debug)
log_debug ("request='%s'\n", request);
xfree (response);