From: Filippo Negroni <fnegroni@flexerasoftware.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org
Subject: [PATCH] Fix gitmkdtemp: correct test for mktemp() return value
Date: Thu, 25 Feb 2010 10:01:31 +0000 [thread overview]
Message-ID: <4B864A7B.9000500@flexerasoftware.com> (raw)
>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 reply other threads:[~2010-02-25 10:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-25 10:01 Filippo Negroni [this message]
2010-02-25 17:33 ` [PATCH] Fix gitmkdtemp: correct test for mktemp() return value Junio C Hamano
2010-02-25 18:05 ` Matthieu Moy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B864A7B.9000500@flexerasoftware.com \
--to=fnegroni@flexerasoftware.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).