Bug 2249
Summary: | mktemp fails (it does nothing) | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | jay |
Component: | glibc | Assignee: | Cristian Gafton <gafton> |
Status: | CLOSED WONTFIX | QA Contact: | |
Severity: | high | Docs Contact: | |
Priority: | high | ||
Version: | 6.0 | CC: | jay |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 1999-07-02 20:59:10 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
jay
1999-04-18 14:33:19 UTC
This issue has been forwarded to a developer for further action. You are using mktemp incorrectly. It expects 6 X's to be passed. It may also fail so you should check the return code mktemp /tmp/foo.XXXXXX works for me ------- Email Received From James Youngman <jay> 06/17/99 00:37 ------- Confirmed. Looks like a tiny glibc bug wants fixing. Contents of the mail message: Oops. The original bug report was for mktemp(3), not mktemp(1). Well, as Alan pointed out, I had miscounted the Xs in the function argument. However, there is still a bug. Where the argument does not end in SIX 'X' characters, the function fails to return NULL. Here is a much simpler example:- [james@periwinkle james]$ make mktemp-test cc mktemp-test.c -o mktemp-test [james@periwinkle james]$ ./mktemp-test mktemp returns '' (0xbffff798) [james@periwinkle james]$ cat mktemp-test.c #include <stdio.h> #include <stdlib.h> int main() { char tmp[] = "/tmp/test.XXXXX"; /* Note! only 5 Xs! */ char * p = mktemp(tmp); printf("mktemp returns '%s' (%p)\n", p ? p : "NULL", (void*)p); return 0; } [james@periwinkle james]$ cat /etc/redhat-release Red Hat Linux release 6.0 (Hedwig) [james@periwinkle james]$ From the manpage:- RETURN VALUE The mktemp() function returns NULL on error (template did not end in XXXXXX) and template otherwise. [...] Well, POSIX says: RETURN VALUE The mktemp() function returns the pointer template. If a unique name cannot be created, template points to a null string. [...] So the current operation is correct. The man page will be fixed to reflect that. |