Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jan 1996 20:19:00 -0800
From:      Josh MacDonald <jmacd@CS.Berkeley.EDU>
To:        freebsd-hackers@freebsd.org
Subject:   mktemp() sucks, why not fix it?
Message-ID:  <199601120419.UAA07014@paris.CS.Berkeley.EDU>

next in thread | raw e-mail | index | archive | help

I don't like how:

main()
{
    char buf1[] = "/tmp/foo.XXXXXX", buf2[] = "/tmp/foo.XXXXXX";
    mktemp(buf1);
    symlink("/tmp/existsbutnotdirectory/foo", buf1);
    if(mktemp(buf2) == NULL)
        perror("mktemp() failed");
    printf("buf1 = %s\nbuf2 = %s\n", buf1, buf2);
}

the second call to mktemp() fails, and they both end up
with the same value.

or how:

main()
{
    char buf1[] = "/tmp/foo.XXXXXX", buf2[] = "/tmp/foo.XXXXXX";
    mktemp(buf1);
    symlink("some_non_existant_file", buf1);
    mktemp(buf2);
    printf("buf1 = %s\nbuf2 = %s\n", buf1, buf2);
}

succeeds but they both have the same value.

that sucks.  why did they use stat() in mktemp?  ick.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601120419.UAA07014>