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

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