From 551ff842721d6ca83727dbe6cd40178f46cc8201 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 16 Sep 2018 19:13:38 +0100 Subject: 43464: Another attachtty() fix. If list_pipe_job triggered more than once we need to know the most recent process group leader, so record that both if the attach happened in the main shell on in entersubsh(). Also don't pass back proocess group for ESUB_ASYNC subshells. --- Src/utils.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index 075d27241..5a9fbdd32 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -4670,6 +4670,10 @@ attachtty(pid_t pgrp) ep = 1; } } + else + { + last_attached_pgrp = pgrp; + } } } -- cgit v1.2.3 From bf9da44931de98984b9eae0dd7b207d433abd59c Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 14 Oct 2018 14:02:12 +0000 Subject: unposted: internals: Document sepjoin(). --- ChangeLog | 2 ++ Src/utils.c | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index deb9aa9b2..968194be1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2018-10-14 Daniel Shahaf + * unposted: Src/utils.c: internals: Document sepjoin(). + * 43685: Functions/Misc/add-zle-hook-widget: Support running under NO_UNSET ('set -u'). diff --git a/Src/utils.c b/Src/utils.c index 5a9fbdd32..914e30c5c 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -3820,6 +3820,14 @@ wordcount(char *s, char *sep, int mul) return r; } +/* + * 's' is a NULL-terminated array of strings. + * 'sep' is a string. + * + * Return a string consisting of the elements of 's' joined by 'sep', + * allocated on the heap iff 'heap'. + */ + /**/ mod_export char * sepjoin(char **s, char *sep, int heap) -- cgit v1.2.3 From d50e204b0c4c10164a711bf640500e46987de9c3 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 7 Nov 2018 14:04:56 +0100 Subject: 43790: failed mailstat could leak memory --- ChangeLog | 2 ++ Src/utils.c | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index 343038997..f915182f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2018-11-09 Peter Stephenson + * 43790: Kamil: Src/utils.c: failed mailstat could leak memory. + * 43789: Kamil: Src/module.c: possible use after free handling math functions from module. diff --git a/Src/utils.c b/Src/utils.c index 914e30c5c..e43a3cdb4 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -7459,19 +7459,28 @@ mailstat(char *path, struct stat *st) /* See if cur/ is present */ dir = appstr(ztrdup(path), "/cur"); - if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0; + if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) { + zsfree(dir); + return 0; + } st_ret.st_atime = st_tmp.st_atime; /* See if tmp/ is present */ dir[plen] = 0; dir = appstr(dir, "/tmp"); - if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0; + if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) { + zsfree(dir); + return 0; + } st_ret.st_mtime = st_tmp.st_mtime; /* And new/ */ dir[plen] = 0; dir = appstr(dir, "/new"); - if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0; + if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) { + zsfree(dir); + return 0; + } st_ret.st_mtime = st_tmp.st_mtime; #if THERE_IS_EXACTLY_ONE_MAILDIR_IN_MAILPATH @@ -7483,6 +7492,7 @@ mailstat(char *path, struct stat *st) st_tmp.st_atime == st_new_last.st_atime && st_tmp.st_mtime == st_new_last.st_mtime) { *st = st_ret_last; + zsfree(dir); return 0; } st_new_last = st_tmp; -- cgit v1.2.3