Blame SOURCES/zsh-5.0.2-PATH_MAX-extra-byte.patch

495835
From d670cfc55d96b65e124b09430d8f43909939fc55 Mon Sep 17 00:00:00 2001
495835
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
495835
Date: Thu, 17 Nov 2016 19:49:17 +0000
495835
Subject: [PATCH] 39958: Add extra byte to PATH_MAX allocations.
495835
495835
This ensures we've got enough space for a null, although this
495835
isn't always needed.
495835
495835
Upstream-commit: a62e1640bcafbb82d86ea8d8ce057a83c4683d60
495835
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
495835
---
495835
 Src/builtin.c |  2 +-
495835
 Src/compat.c  |  4 ++--
495835
 Src/exec.c    | 16 ++++++++--------
495835
 Src/glob.c    |  4 ++--
495835
 Src/hist.c    |  2 +-
495835
 Src/utils.c   |  6 +++---
495835
 6 files changed, 17 insertions(+), 17 deletions(-)
495835
495835
diff --git a/Src/builtin.c b/Src/builtin.c
495835
index caa4b64..86d7d9a 100644
495835
--- a/Src/builtin.c
495835
+++ b/Src/builtin.c
495835
@@ -945,7 +945,7 @@ cd_do_chdir(char *cnam, char *dest, int hard)
495835
      * Normalize path under Cygwin to avoid messing with
495835
      * DOS style names with drives in them
495835
      */
495835
-    static char buf[PATH_MAX];
495835
+    static char buf[PATH_MAX+1];
495835
 #ifndef _SYS_CYGWIN_H
495835
     void cygwin_conv_to_posix_path(const char *, char *);
495835
 #endif
495835
diff --git a/Src/compat.c b/Src/compat.c
495835
index cc4e876..d81e3d6 100644
495835
--- a/Src/compat.c
495835
+++ b/Src/compat.c
495835
@@ -270,7 +270,7 @@ zgetdir(struct dirsav *d)
495835
     int len;
495835
 #endif
495835
 
495835
-    buf = zhalloc(bufsiz = PATH_MAX);
495835
+    buf = zhalloc(bufsiz = PATH_MAX+1);
495835
     pos = bufsiz - 1;
495835
     buf[pos] = '\0';
495835
     strcpy(nbuf, "../");
495835
@@ -439,7 +439,7 @@ zgetcwd(void)
495835
 	    free(cwd);
495835
 	}
495835
 #else
495835
-	char *cwdbuf = zalloc(PATH_MAX);
495835
+	char *cwdbuf = zalloc(PATH_MAX+1);
495835
 	ret = getcwd(cwdbuf, PATH_MAX);
495835
 	if (ret)
495835
 	    ret = dupstring(ret);
495835
diff --git a/Src/exec.c b/Src/exec.c
495835
index c95667e..03716ba 100644
495835
--- a/Src/exec.c
495835
+++ b/Src/exec.c
495835
@@ -434,7 +434,7 @@ static int
495835
 zexecve(char *pth, char **argv, char **newenvp)
495835
 {
495835
     int eno;
495835
-    static char buf[PATH_MAX * 2];
495835
+    static char buf[PATH_MAX * 2+1];
495835
     char **eep;
495835
 
495835
     unmetafy(pth, NULL);
495835
@@ -575,7 +575,7 @@ static void
495835
 execute(LinkList args, int flags, int defpath)
495835
 {
495835
     Cmdnam cn;
495835
-    char buf[MAXCMDLEN], buf2[MAXCMDLEN];
495835
+    char buf[MAXCMDLEN+1], buf2[MAXCMDLEN+1];
495835
     char *s, *z, *arg0;
495835
     char **argv, **pp, **newenvp = NULL;
495835
     int eno = 0, ee;
495835
@@ -656,7 +656,7 @@ execute(LinkList args, int flags, int defpath)
495835
 
495835
     /* for command -p, search the default path */
495835
     if (defpath) {
495835
-	char *s, pbuf[PATH_MAX];
495835
+	char *s, pbuf[PATH_MAX+1];
495835
 	char *dptr, *pe, *ps = DEFAULT_PATH;
495835
 
495835
 	for(;ps;ps = pe ? pe+1 : NULL) {
495835
@@ -693,7 +693,7 @@ execute(LinkList args, int flags, int defpath)
495835
     } else {
495835
 
495835
 	if ((cn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, arg0))) {
495835
-	    char nn[PATH_MAX], *dptr;
495835
+	    char nn[PATH_MAX+1], *dptr;
495835
 
495835
 	    if (cn->node.flags & HASHED)
495835
 		strcpy(nn, cn->u.cmd);
495835
@@ -778,7 +778,7 @@ findcmd(char *arg0, int docopy)
495835
 	    break;
495835
 	}
495835
     if (cn) {
495835
-	char nn[PATH_MAX];
495835
+	char nn[PATH_MAX+1];
495835
 
495835
 	if (cn->node.flags & HASHED)
495835
 	    strcpy(nn, cn->u.cmd);
495835
@@ -859,7 +859,7 @@ mod_export Cmdnam
495835
 hashcmd(char *arg0, char **pp)
495835
 {
495835
     Cmdnam cn;
495835
-    char *s, buf[PATH_MAX];
495835
+    char *s, buf[PATH_MAX+1];
495835
     char **pq;
495835
 
495835
     for (; *pp; pp++)
495835
@@ -4919,7 +4919,7 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name)
495835
 Eprog
495835
 getfpfunc(char *s, int *ksh, char **fname)
495835
 {
495835
-    char **pp, buf[PATH_MAX];
495835
+    char **pp, buf[PATH_MAX+1];
495835
     off_t len;
495835
     off_t rlen;
495835
     char *d;
495835
@@ -5047,7 +5047,7 @@ cancd(char *s)
495835
     char *t;
495835
 
495835
     if (*s != '/') {
495835
-	char sbuf[PATH_MAX], **cp;
495835
+	char sbuf[PATH_MAX+1], **cp;
495835
 
495835
 	if (cancd2(s))
495835
 	    return s;
495835
diff --git a/Src/glob.c b/Src/glob.c
495835
index 9135fce..92ed8b5 100644
495835
--- a/Src/glob.c
495835
+++ b/Src/glob.c
495835
@@ -271,7 +271,7 @@ addpath(char *s, int l)
495835
 static int
495835
 statfullpath(const char *s, struct stat *st, int l)
495835
 {
495835
-    char buf[PATH_MAX];
495835
+    char buf[PATH_MAX+1];
495835
 
495835
     DPUTS(strlen(s) + !*s + pathpos - pathbufcwd >= PATH_MAX,
495835
 	  "BUG: statfullpath(): pathname too long");
495835
@@ -775,7 +775,7 @@ parsepat(char *str)
495835
 
495835
     /* Now there is no (#X) in front, we can check the path. */
495835
     if (!pathbuf)
495835
-	pathbuf = zalloc(pathbufsz = PATH_MAX);
495835
+	pathbuf = zalloc(pathbufsz = PATH_MAX+1);
495835
     DPUTS(pathbufcwd, "BUG: glob changed directory");
495835
     if (*str == '/') {		/* pattern has absolute path */
495835
 	str++;
495835
diff --git a/Src/hist.c b/Src/hist.c
495835
index 9a63c15..6764eaf 100644
495835
--- a/Src/hist.c
495835
+++ b/Src/hist.c
495835
@@ -1658,7 +1658,7 @@ chrealpath(char **junkptr)
495835
     char *lastpos, *nonreal, *real;
495835
 #else
495835
 # ifdef HAVE_REALPATH
495835
-    char *lastpos, *nonreal, real[PATH_MAX];
495835
+    char *lastpos, *nonreal, real[PATH_MAX+1];
495835
 # endif
495835
 #endif
495835
 
495835
diff --git a/Src/utils.c b/Src/utils.c
495835
index 05eeda4..13910a4 100644
495835
--- a/Src/utils.c
495835
+++ b/Src/utils.c
495835
@@ -930,7 +930,7 @@ finddir(char *s)
495835
 	if(homenode.diff==1)
495835
 	    homenode.diff = 0;
495835
 	if(!finddir_full)
495835
-	    finddir_full = zalloc(ffsz = PATH_MAX);
495835
+	    finddir_full = zalloc(ffsz = PATH_MAX+1);
495835
 	finddir_full[0] = 0;
495835
 	return finddir_last = NULL;
495835
     }
495835
@@ -1418,7 +1418,7 @@ checkmailpath(char **s)
495835
 	} else if (S_ISDIR(st.st_mode)) {
495835
 	    LinkList l;
495835
 	    DIR *lock = opendir(unmeta(*s));
495835
-	    char buf[PATH_MAX * 2], **arr, **ap;
495835
+	    char buf[PATH_MAX * 2 + 1], **arr, **ap;
495835
 	    int buflen, ct = 1;
495835
 
495835
 	    if (lock) {
495835
@@ -5828,7 +5828,7 @@ strsfx(char *s, char *t)
495835
 static int
495835
 upchdir(int n)
495835
 {
495835
-    char buf[PATH_MAX];
495835
+    char buf[PATH_MAX+1];
495835
     char *s;
495835
     int err = -1;
495835
 
495835
-- 
495835
2.20.1
495835