* [PATCH] Fix gitmkdtemp: correct test for mktemp() return value
@ 2010-02-25 10:01 Filippo Negroni
2010-02-25 17:33 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Filippo Negroni @ 2010-02-25 10:01 UTC (permalink / raw)
To: gitster; +Cc: git
>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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix gitmkdtemp: correct test for mktemp() return value
2010-02-25 10:01 [PATCH] Fix gitmkdtemp: correct test for mktemp() return value Filippo Negroni
@ 2010-02-25 17:33 ` Junio C Hamano
2010-02-25 18:05 ` Matthieu Moy
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2010-02-25 17:33 UTC (permalink / raw)
To: Filippo Negroni; +Cc: git
Filippo Negroni <fnegroni@flexerasoftware.com> writes:
> 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>
> ---
Thanks.
Next time please do not quote the mbox header lines (i.e. start your body
with "In gitmkdtemp, the return value ...".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix gitmkdtemp: correct test for mktemp() return value
2010-02-25 17:33 ` Junio C Hamano
@ 2010-02-25 18:05 ` Matthieu Moy
0 siblings, 0 replies; 3+ messages in thread
From: Matthieu Moy @ 2010-02-25 18:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Filippo Negroni, git
Junio C Hamano <gitster@pobox.com> writes:
> Next time please do not quote the mbox header lines (i.e. start your body
> with "In gitmkdtemp, the return value ...".
... or just use "git send-email", which does the trick for you.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-02-25 18:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-25 10:01 [PATCH] Fix gitmkdtemp: correct test for mktemp() return value Filippo Negroni
2010-02-25 17:33 ` Junio C Hamano
2010-02-25 18:05 ` Matthieu Moy
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).