From: Junio C Hamano Date: Mon, 21 Mar 2011 05:09:39 +0000 (-0700) Subject: Merge branch 'ae/better-template-failure-report' into maint X-Git-Tag: v1.7.4.2~9 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a8e04ddf6e3fc444469e6f0f2f4690c04c0290ab?ds=inline;hp=-c Merge branch 'ae/better-template-failure-report' into maint * ae/better-template-failure-report: Improve error messages when temporary file creation fails --- a8e04ddf6e3fc444469e6f0f2f4690c04c0290ab diff --combined Makefile index 775ee838c3,03a51cb8f2..ade79232f4 --- a/Makefile +++ b/Makefile @@@ -431,10 -431,10 +431,11 @@@ TEST_PROGRAMS_NEED_X += test-run-comman TEST_PROGRAMS_NEED_X += test-sha1 TEST_PROGRAMS_NEED_X += test-sigchain TEST_PROGRAMS_NEED_X += test-string-pool +TEST_PROGRAMS_NEED_X += test-subprocess TEST_PROGRAMS_NEED_X += test-svn-fe TEST_PROGRAMS_NEED_X += test-treap TEST_PROGRAMS_NEED_X += test-index-version + TEST_PROGRAMS_NEED_X += test-mktemp TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X)) @@@ -1004,7 -1004,6 +1005,7 @@@ ifeq ($(uname_S),IRIX # issue, comment out the NO_MMAP statement. NO_MMAP = YesPlease NO_REGEX = YesPlease + NO_FNMATCH_CASEFOLD = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease SHELL_PATH = /usr/gnu/bin/bash NEEDS_LIBGEN = YesPlease @@@ -1024,7 -1023,6 +1025,7 @@@ ifeq ($(uname_S),IRIX64 # issue, comment out the NO_MMAP statement. NO_MMAP = YesPlease NO_REGEX = YesPlease + NO_FNMATCH_CASEFOLD = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease SHELL_PATH=/usr/gnu/bin/bash NEEDS_LIBGEN = YesPlease diff --combined wrapper.c index 79635f2e16,55b074ec46..4c147d6c48 --- a/wrapper.c +++ b/wrapper.c @@@ -53,7 -53,7 +53,7 @@@ void *xmalloc(size_t size void *xmallocz(size_t size) { void *ret; - if (size + 1 < size) + if (unsigned_add_overflows(size, 1)) die("Data too large to fit into virtual memory space."); ret = xmalloc(size + 1); ((char*)ret)[size] = 0; @@@ -198,10 -198,22 +198,22 @@@ FILE *xfdopen(int fd, const char *mode int xmkstemp(char *template) { int fd; + char origtemplate[PATH_MAX]; + strlcpy(origtemplate, template, sizeof(origtemplate)); fd = mkstemp(template); - if (fd < 0) - die_errno("Unable to create temporary file"); + if (fd < 0) { + int saved_errno = errno; + const char *nonrelative_template; + + if (!template[0]) + template = origtemplate; + + nonrelative_template = make_nonrelative_path(template); + errno = saved_errno; + die_errno("Unable to create temporary file '%s'", + nonrelative_template); + } return fd; } @@@ -321,10 -333,22 +333,22 @@@ int gitmkstemps(char *pattern, int suff int xmkstemp_mode(char *template, int mode) { int fd; + char origtemplate[PATH_MAX]; + strlcpy(origtemplate, template, sizeof(origtemplate)); fd = git_mkstemp_mode(template, mode); - if (fd < 0) - die_errno("Unable to create temporary file"); + if (fd < 0) { + int saved_errno = errno; + const char *nonrelative_template; + + if (!template[0]) + template = origtemplate; + + nonrelative_template = make_nonrelative_path(template); + errno = saved_errno; + die_errno("Unable to create temporary file '%s'", + nonrelative_template); + } return fd; }