From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: linux-c-programming@vger.kernel.org
Cc: Progga <abulfazl@juniv.edu>
Subject: Re: mktemp()
Date: Sat, 5 Jun 2004 13:16:48 +0200 [thread overview]
Message-ID: <20040605111647.GW20632@lug-owl.de> (raw)
In-Reply-To: <20040605141705.A681@Imrashi.net.bd>
[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]
On Sat, 2004-06-05 14:17:05 +0600, Progga <abulfazl@juniv.edu>
wrote in message <20040605141705.A681@Imrashi.net.bd>:
> On Sat, Jun 05, 2004 at 05:55:26AM +0100, Glynn Clements wrote:
> Does the above mean that mktemp( "abcXXXXXX" ) can return "abc123456" even if
> there's a symlink with the name "abc123456" ?
No. This one has good chances to SIGSEGV before it returns at all:)
---------------------------------
char *my_temp_template = "abcXXXXXX";
char *my_temp_file;
my_temp_file = mktemp (my_temp_template);
if (!my_temp_file)
errex ("Couldn't create temp file\n");
---------------------------------
The above one may SEGV as well, because the template may be stored in
memory marked as read-only.
This one will work:
---------------------------------
char my_temp_template[] = "abcXXXXXX";
char *my_temp_file;
my_temp_file = mktemp (my_temp_template);
if (!my_temp_file)
errex ("Couldn't create temp file\n");
---------------------------------
Also, I remember there was at least one compiler (some older MAC OS?)
which didn't add the final \0 on it's own to xxx[]...
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak!
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2004-06-05 11:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-05 3:30 mktemp() Progga
2004-06-05 4:55 ` mktemp() Glynn Clements
2004-06-05 8:17 ` mktemp() Progga
2004-06-05 11:16 ` Jan-Benedict Glaw [this message]
2004-06-05 12:40 ` mktemp() Progga
2004-06-05 13:18 ` mktemp() Jan-Benedict Glaw
2004-06-05 19:42 ` mktemp() Glynn Clements
2004-06-05 22:43 ` mktemp() Progga
2004-06-06 9:50 ` mktemp() Martin Olsson
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=20040605111647.GW20632@lug-owl.de \
--to=jbglaw@lug-owl.de \
--cc=abulfazl@juniv.edu \
--cc=linux-c-programming@vger.kernel.org \
/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).