git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tay Ray Chuan <rctay89@gmail.com>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Jeff Lasslett <jeff.lasslett@gmail.com>
Subject: [PATCH (resend) 3/3] Check return value of ftruncate call in http.c
Date: Tue, 11 Aug 2009 00:05:06 +0800	[thread overview]
Message-ID: <20090811000506.c63eb8f1.rctay89@gmail.com> (raw)
In-Reply-To: <20090810235955.1a659e6c.rctay89@gmail.com>

From: Jeff Lasslett <jeff.lasslett@gmail.com>

In new_http_object_request(), check ftruncate() call return value and
handle possible errors.

Signed-off-by: Jeff Lasslett <jeff.lasslett@gmail.com>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---

 Jeff, I took out all the url-specific cleanups and expanded their
 scope (see earlier patches). You can safely focus on ftruncate() and
 do an abort there. :)

 http.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/http.c b/http.c
index 98f9707..14d5357 100644
--- a/http.c
+++ b/http.c
@@ -1187,7 +1187,11 @@ struct http_object_request *new_http_object_request(const char *base_url,
 		if (prev_posn>0) {
 			prev_posn = 0;
 			lseek(freq->localfile, 0, SEEK_SET);
-			ftruncate(freq->localfile, 0);
+			if (ftruncate(freq->localfile, 0) < 0) {
+				error("Couldn't truncate temporary file %s for %s: %s",
+					  freq->tmpfile, freq->filename, strerror(errno));
+				goto abort;
+			}
 		}
 	}

--
1.6.3.1

  reply	other threads:[~2009-08-10 16:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10 13:42 [PATCH] Check return value of ftruncate call in http.c. Remove possible mem leak Jeff Lasslett
2009-08-10 15:47 ` Tay Ray Chuan
2009-08-10 15:55   ` [PATCH (resend) 1/3] http.c: free preq when aborting Tay Ray Chuan
2009-08-10 15:59     ` [PATCH (resend) 2/3] http.c: replace usage of temporary variable for urls Tay Ray Chuan
2009-08-10 16:05       ` Tay Ray Chuan [this message]
2009-08-11  5:13         ` [PATCH (resend) 3/3] Check return value of ftruncate call in http.c Junio C Hamano

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=20090811000506.c63eb8f1.rctay89@gmail.com \
    --to=rctay89@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeff.lasslett@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).