aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine-spawn.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-05-08 18:35:57 +0000
committerWerner Koch <[email protected]>2014-05-08 18:35:57 +0000
commitde4a1ea684e1591975feb801e7651309e1ee2c49 (patch)
tree0ff9ef71c8fa36809d10e00bd04c5b5a4ff4252e /src/engine-spawn.c
parentMap public key algos returned by gpg to gpgme values. (diff)
downloadgpgme-de4a1ea684e1591975feb801e7651309e1ee2c49.tar.gz
gpgme-de4a1ea684e1591975feb801e7651309e1ee2c49.zip
Fix a memory access and a double slash bug.
* src/engine-spawn.c (engspawn_start): Allocate space for list terminator. * src/posix-util.c (walk_path): Fix trailing slash detection. -- Kudos to Valgrind for pointing out these two problems. The first is a plain allocation bug in a code pattern I have written thousands of times - this time it went wrong. The allocation is not user controlled thus not directly exploitable. The second is missed to do what it intended to do. Found due to the access of malloced but not initialized memory. Not using calloc again proved to be helpful to detect logical error.
Diffstat (limited to 'src/engine-spawn.c')
-rw-r--r--src/engine-spawn.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/engine-spawn.c b/src/engine-spawn.c
index bfcad3d9..8ffc6280 100644
--- a/src/engine-spawn.c
+++ b/src/engine-spawn.c
@@ -250,7 +250,7 @@ engspawn_start (engine_spawn_t esp, const char *file, const char *argv[],
n = 0;
for (i = 0; esp->fd_data_map[i].data; i++)
n++;
- fd_list = calloc (n, sizeof *fd_list);
+ fd_list = calloc (n+1, sizeof *fd_list);
if (!fd_list)
return gpg_error_from_syserror ();