From: Linus Torvalds Date: Sun, 29 May 2005 19:06:32 +0000 (-0700) Subject: git-mktag: be more careful in reading the input. X-Git-Tag: v0.99~419 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b97e3dfa7699776cd4bcc1a712e884992d757f40;p=git.git 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. --- diff --git a/mktag.c b/mktag.c index aa4a6d863..8cbbef67e 100644 --- a/mktag.c +++ b/mktag.c @@ -106,7 +106,18 @@ int main(int argc, char **argv) usage("cat | 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 \ntype " if (verify_tag(buffer, size) < 0)