xmkstemp(): avoid showing truncated template more carefully
Some implementations of xmkstemp() leaves the given in/out buffer truncated when they return with failure. 6cf6bb3 (Improve error messages when temporary file creation fails, 2010-12-18) attempted to show the real filename we tried to create (but failed), and if that is not available due to such truncation, to show the original template that was given by the caller. But it failed to take into account that the given template could have "directory/" in front, in which case the truncation point may not be template[0] but somewhere else. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Dec 18, 2012 at 12:51 UTC
f7be59b4770a8a8b76c1d0612db409ce7e8d11f2
1 file changed
+1
-1
wrapper.c
+1
-1
@@ -229,7 +229,7 @@ int xmkstemp(char *template)
229
int saved_errno = errno;
230
const char *nonrelative_template;
231
232
- if (!template[0])
232
+ if (strlen(template) != strlen(origtemplate))
233
template = origtemplate;
234
235
nonrelative_template = absolute_path(template);