mktemp() isn't a solution, since it is still raceable. mkstemp() is the solution.
In OpenBSD we've killed about 400 or so of these; some exploitable, some perhaps not.