summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-12-19 16:21:55 +0700
committerJunio C Hamano <gitster@pobox.com>2016-12-20 12:08:06 -0800
commit29647d79a9a29498675ccb137f567a44dc9628b8 (patch)
tree6af0fdf973be0c407ac64229ee6729080eeab28e /config.c
parent0202c411edc25940cc381bf317badcdf67670be4 (diff)
downloadgit-29647d79a9a29498675ccb137f567a44dc9628b8.tar.gz
config.c: handle error case for fstat() calls
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/config.c b/config.c
index d7ce34b33d..19ceb2639e 100644
--- a/config.c
+++ b/config.c
@@ -2107,7 +2107,12 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
goto out_free;
}
- fstat(in_fd, &st);
+ if (fstat(in_fd, &st) == -1) {
+ error_errno(_("fstat on %s failed"), config_filename);
+ ret = CONFIG_INVALID_FILE;
+ goto out_free;
+ }
+
contents_sz = xsize_t(st.st_size);
contents = xmmap_gently(NULL, contents_sz, PROT_READ,
MAP_PRIVATE, in_fd, 0);
@@ -2327,7 +2332,10 @@ int git_config_rename_section_in_file(const char *config_filename,
goto unlock_and_out;
}
- fstat(fileno(config_file), &st);
+ if (fstat(fileno(config_file), &st) == -1) {
+ ret = error_errno(_("fstat on %s failed"), config_filename);
+ goto out;
+ }
if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
ret = error_errno("chmod on %s failed",