about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-11-07 23:57:27 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-11-07 23:57:27 +0000
commita3055b2363b29b7a1569bb2da3a95116cc33dd27 (patch)
treeb843914892167a6ac9d65142f665ee22dd5a99c5
parentbce9aa947dc880eda3549e0bed65c0f5911c9df1 (diff)
downloadzsh-a3055b2363b29b7a1569bb2da3a95116cc33dd27.tar.gz
zsh-a3055b2363b29b7a1569bb2da3a95116cc33dd27.tar.xz
zsh-a3055b2363b29b7a1569bb2da3a95116cc33dd27.zip
Mikael: 27362: some more attr fixes
-rw-r--r--ChangeLog6
-rw-r--r--Src/Modules/attr.c12
2 files changed, 11 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 3e509ea6b..7d9144080 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-11-07  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* Mikael: 27362: Src/Modules/attr.c: some more fixes.
+
 2009-11-07  Clint Adams  <clint@zsh.org>
 
 	* Frank Terbeck: 27359: Completion/Unix/Command/.distfiles,
@@ -12313,5 +12317,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4805 $
+* $Revision: 1.4806 $
 *****************************************************
diff --git a/Src/Modules/attr.c b/Src/Modules/attr.c
index 2cdb522c1..6e08b10c5 100644
--- a/Src/Modules/attr.c
+++ b/Src/Modules/attr.c
@@ -98,7 +98,7 @@ static int
 bin_getattr(char *nam, char **argv, Options ops, UNUSED(int func))
 {
     int ret = 0;
-    int list_len, val_len, attr_len, slen;
+    int list_len, val_len = 0, attr_len = 0, slen;
     char *value, *file = argv[0], *attr = argv[1], *param = argv[2];
     int symlink = OPT_ISSET(ops, 'h');
 
@@ -125,9 +125,9 @@ bin_getattr(char *nam, char **argv, Options ops, UNUSED(int func))
             zfree(value, val_len+1);
         }
     }
-    if (list_len < 0 || val_len < 0 || attr_len < 0)  {
+    if (list_len < 0 || val_len < 0 || attr_len < 0 || attr_len > val_len)  {
         zwarnnam(nam, "%s: %e", metafy(file, slen, META_NOALLOC), errno);
-        ret = 1 + (attr_len > val_len);
+        ret = 1 + (attr_len > val_len || attr_len < 0);
     }
     return ret;
 }
@@ -172,7 +172,7 @@ static int
 bin_listattr(char *nam, char **argv, Options ops, UNUSED(int func))
 {
     int ret = 0;
-    int val_len, list_len, slen;
+    int val_len, list_len = 0, slen;
     char *value, *file = argv[0], *param = argv[1];
     int symlink = OPT_ISSET(ops, 'h');
 
@@ -214,9 +214,9 @@ bin_listattr(char *nam, char **argv, Options ops, UNUSED(int func))
         }
         zfree(value, val_len+1);
     }
-    if (val_len < 0 || list_len < 0) {
+    if (val_len < 0 || list_len < 0 || list_len > val_len) {
         zwarnnam(nam, "%s: %e", metafy(file, slen, META_NOALLOC), errno);
-        ret = 1 + (list_len > val_len);
+        ret = 1 + (list_len > val_len || list_len < 0);
     }
     return ret;
 }