Skip to content

Commit f7be59b

Browse files
committed
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 <[email protected]>
1 parent 7e20105 commit f7be59b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ int xmkstemp(char *template)
229229
int saved_errno = errno;
230230
const char *nonrelative_template;
231231

232-
if (!template[0])
232+
if (strlen(template) != strlen(origtemplate))
233233
template = origtemplate;
234234

235235
nonrelative_template = absolute_path(template);

0 commit comments

Comments
 (0)