1 --- tmpnam.c.orig 2010-07-06 16:02:20.000000000 -0700
2 +++ tmpnam.c 2010-07-06 16:32:52.000000000 -0700
3 @@ -40,21 +40,35 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/t
10 __warn_references(tmpnam,
11 "warning: tmpnam() possibly used unsafely; consider using mkstemp()");
13 extern char *_mktemp(char *);
15 +static char *tmpnam_buf = NULL;
16 +static pthread_once_t tmpnam_buf_control = PTHREAD_ONCE_INIT;
18 +static void tmpnam_buf_allocate(void)
20 + tmpnam_buf = malloc(L_tmpnam);
27 static u_long tmpcount;
28 - static char buf[L_tmpnam];
33 + if (pthread_once(&tmpnam_buf_control, tmpnam_buf_allocate)
39 (void)snprintf(s, L_tmpnam, "%stmp.%lu.XXXXXX", P_tmpdir, tmpcount);