From: Chris Wilson <cwilson@vigilantsw.com>
To: git@vger.kernel.org
Subject: [PATCH] Fix useless comparison bug
Date: Thu, 26 May 2011 10:01:52 -0400 [thread overview]
Message-ID: <20110526140152.GA19748@localhost> (raw)
The variable 'actual' was declared with a size_t type. In this line:
actual = read_in_full(fd, buf, sz);
read_in_full returns a ssize_t type. Since size_t is unsigned and
ssize_t is signed, the value is implicitly converted from a signed
type to an unsigned type. That makes this comparison useless,
if (actual < 0)
die_errno("index-stream: reading input");
as it will always be false. This means, on an error path, git will
continue when it should die gracefully.
This bug was introduced in 4dd1fbc.
Signed-off-by: Chris Wilson <cwilson@vigilantsw.com>
---
Hi Folks,
Sentry found this committed in last nights snapshot.
Chris Wilson
http://vigilantsw.com/
Vigilant Software
sha1_file.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 064a330..c251af8 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2704,7 +2704,7 @@ static int index_stream(unsigned char *sha1, int fd, size_t size,
while (size) {
char buf[10240];
size_t sz = size < sizeof(buf) ? size : sizeof(buf);
- size_t actual;
+ ssize_t actual;
actual = read_in_full(fd, buf, sz);
if (actual < 0)
--
1.6.3.3
reply other threads:[~2011-05-26 14:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110526140152.GA19748@localhost \
--to=cwilson@vigilantsw.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.