Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Some more fixes for the attr module
- X-seq: zsh-workers 27362
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Some more fixes for the attr module
- Date: Sat, 7 Nov 2009 20:10:48 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=9LX9tLdEtEDEsdvgZ2KfEy7lH/WVpQzTrHvjcaZrRpg=; b=bu+0K+3vYesbLV3ltDYvvCR8RnAKG8cjJ5Li4hyPXj0KhytNM1uf9vqbox1mXhfpn0 atTVLoggjY7MtSADTHmlwcO810Vwm0pFvxPcXrBdZl8eNrurvq9G3DVLFcwLKtIEBgXH x77NZX+NGWI2xzvKSLpZ/CeTPECwehzjk6nP4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ikbx1NQPTt2+DxwjD0dXYBaRNe6h4kMEeky/TJfym++hGp95UWRKY4vR4ckYuDIFaW vvkqrfUX/HJooqS84JvSkcHWpljek/DnqYna7ftPOxDVC92dz8lNs67vM8GkPSEjou+/ dFYanrYiZ3+OuQOA3KRMww6MCsVx0YNv46GcI=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
I ran clang 2.6 in analyze mode on zsh and it picked up some mistakes
I made with the error handling (patch attached). If anyone wants to
look at the rest i tarred up the reports and put them here, but most
of them are likely to be false positives (7.3MB packed)
http://mika.l3ib.org/zsh-clang-2009-11-06.tar.gz
--
Mikael Magnusson
From: Mikael Magnusson <mikachu@xxxxxxxxx>
Date: Fri, 6 Nov 2009 23:40:10 +0100
Subject: [PATCH] attr: Fix some logic errors pointed out by clang
Three _len variables were checked when they were uninitialized
The case for returning 2 could never occur
---
Src/Modules/attr.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Src/Modules/attr.c b/Src/Modules/attr.c
index 7234862..a9e9949 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;
}
--
1.6.5
Messages sorted by:
Reverse Date,
Date,
Thread,
Author