git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix gitmkdtemp: correct test for mktemp() return value

From
FNFilippo Negroni <fnegroni@flexerasoftware.com>
Date
Feb 25, 2010, 10:01 UTC
Message-ID
<4B864A7B.9000500@flexerasoftware.com>
>From 5e3b362cdd86150de901312c01beac9596b7e2ba Mon Sep 17 00:00:00 2001
From: Filippo Negroni <fnegroni@flexerasoftware.com>
Date: Thu, 25 Feb 2010 09:39:56 +0000
Subject: [PATCH] Fix gitmkdtemp: correct test for mktemp() return value

In gitmkdtemp, the return value of mktemp is not tested correctly. mktemp() always returns its 'template' argument, even upon failre. Upon failure, mktemp sets template to be an empty string: its first character is '\0'. This patch ensures the return value of mktemp is correctly tested by dereferencing the pointer returned by it.

Signed-off-by: Filippo Negroni <fnegroni@flexerasoftware.com>
---
 compat/mkdtemp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/compat/mkdtemp.c b/compat/mkdtemp.c
index 34d4b49..1136119 100644
--- a/compat/mkdtemp.c
+++ b/compat/mkdtemp.c
@@ -2,7 +2,7 @@
 
 char *gitmkdtemp(char *template)
 {
-       if (!mktemp(template) || mkdir(template, 0700))
+       if (!*mktemp(template) || mkdir(template, 0700))
                return NULL;
        return template;
 }
-- 
1.6.4
Next: Junio C Hamano
Message 1 of 3 in “Fix gitmkdtemp: correct test for mktemp() return value”
  1. Fix gitmkdtemp: correct test for mktemp() return valueFilippo Negroni, Feb 25, 2010
  2. Junio C HamanoFeb 25, 2010
  3. Matthieu MoyFeb 25, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.