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 <jeff.lasslett@gmail.com> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Lasslett committed
Aug 11, 2009 at 00:05 UTC
0c4f21e452dca5a705c36ca7e363c1a3b3c2a5b8
1 file changed
+5
-1
http.c
+5
-1
@@ -1187,7 +1187,11 @@ struct http_object_request *new_http_object_request(const char *base_url,
1187
if (prev_posn>0) {
1188
prev_posn = 0;
1189
lseek(freq->localfile, 0, SEEK_SET);
1190
- ftruncate(freq->localfile, 0);
1190
+ if (ftruncate(freq->localfile, 0) < 0) {
1191
+ error("Couldn't truncate temporary file %s for %s: %s",
1192
+ freq->tmpfile, freq->filename, strerror(errno));
1193
+ goto abort;
1194
+ }
1195
}
1196
}
1197