From 0c4f21e452dca5a705c36ca7e363c1a3b3c2a5b8 Mon Sep 17 00:00:00 2001 From: Jeff Lasslett Date: Tue, 11 Aug 2009 00:05:06 +0800 Subject: [PATCH] Check return value of ftruncate call in http.c In new_http_object_request(), check ftruncate() call return value and handle possible errors. Signed-off-by: Jeff Lasslett Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- http.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/http.c b/http.c index 98f9707625..14d535747d 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; + } } } -- GitLab