config.c: avoid xmmap error messages
[gitweb.git] / config.c
index dc7f8b2abc8f994ea7045bdec827a07ef9d2a847..d348d792aabb442981ea407be064815b3d8157c6 100644 (file)
--- a/config.c
+++ b/config.c
@@ -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) {