summaryrefslogtreecommitdiff
path: root/mktag.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-29 19:06:32 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-29 19:06:32 (GMT)
commitb97e3dfa7699776cd4bcc1a712e884992d757f40 (patch)
treef94a915348a16710f7fe618d224c634f5a5e511a /mktag.c
parent8b7d510fb182ca40bd0f905bb2f5543b0d9549de (diff)
downloadgit-b97e3dfa7699776cd4bcc1a712e884992d757f40.zip
git-b97e3dfa7699776cd4bcc1a712e884992d757f40.tar.gz
git-b97e3dfa7699776cd4bcc1a712e884992d757f40.tar.bz2
git-mktag: be more careful in reading the input.
Instead of always assuming it can be read with a single read() system call, loop around properly. Pointed out by Pasky, but I ended up implementing it differently from his suggested patch.
Diffstat (limited to 'mktag.c')
-rw-r--r--mktag.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/mktag.c b/mktag.c
index aa4a6d8..8cbbef6 100644
--- a/mktag.c
+++ b/mktag.c
@@ -106,7 +106,18 @@ int main(int argc, char **argv)
usage("cat <signaturefile> | git-mktag");
// Read the signature
- size = read(0, buffer, MAXSIZE);
+ size = 0;
+ for (;;) {
+ int ret = read(0, buffer + size, MAXSIZE - size);
+ if (!ret)
+ break;
+ if (ret < 0) {
+ if (errno == EAGAIN)
+ continue;
+ break;
+ }
+ size += ret;
+ }
// Verify it for some basic sanity: it needs to start with "object <sha1>\ntype "
if (verify_tag(buffer, size) < 0)