Check return value of ftruncate call in http.c
authorJeff Lasslett <jeff.lasslett@gmail.com>
Mon, 10 Aug 2009 16:05:06 +0000 (00:05 +0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Aug 2009 20:26:18 +0000 (13:26 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http.c

diff --git a/http.c b/http.c
index 98f9707625dd1e28dc3206f76ab27b231c1425a9..14d535747d943c2db3d45d82439f3ee9633ed2d9 100644 (file)
--- 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;
+                       }
                }
        }