diff options
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -2048,8 +2048,15 @@ int git_config_set_multivar_in_file(const char *config_filename, fstat(in_fd, &st); contents_sz = xsize_t(st.st_size); - contents = xmmap(NULL, contents_sz, PROT_READ, - MAP_PRIVATE, in_fd, 0); + contents = xmmap_gently(NULL, contents_sz, PROT_READ, + MAP_PRIVATE, in_fd, 0); + if (contents == MAP_FAILED) { + error("unable to mmap '%s': %s", + config_filename, strerror(errno)); + ret = CONFIG_INVALID_FILE; + contents = NULL; + goto out_free; + } close(in_fd); if (chmod(lock->filename.buf, st.st_mode & 07777) < 0) { |