1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

MINGW: fix tmpnam giving filenames in the root directory

Window's tmpnam expects that you will prepend it with the temporary
directory.  Using _tempnam gives a path that is already prepended
with a temporary directory.

* NEWS: updated
* libguile/posix.c [_WIN32](scm_tmpnam): use _tempnam to create
    a temporary filename
* test-suite/tests/posix.test ("tmpnam"): new test
This commit is contained in:
Michael Gran 2023-07-04 16:07:00 -07:00
parent 12861e2bc2
commit 59f3e1a881
3 changed files with 39 additions and 1 deletions

11
NEWS
View file

@ -54,7 +54,7 @@ by libtool, such as libfoo-1.dll.
Also, it has been updated to do library renaming for MSYS. On Cygwin, Also, it has been updated to do library renaming for MSYS. On Cygwin,
when the #:rename-on-cygwin? option is #t, it already had the capability when the #:rename-on-cygwin? option is #t, it already had the capability
to search for "libfoo" as "cygfoo.dll". It has been updated to add the to search for "libfo[[Oo" as "cygfoo.dll". It has been updated to add the
capability to search for "libfoo" as "msys-foo.dll" on MSYS. capability to search for "libfoo" as "msys-foo.dll" on MSYS.
The load-foreign-library option #:rename-on-cygwin? has been changed to The load-foreign-library option #:rename-on-cygwin? has been changed to
@ -171,6 +171,7 @@ text files.
GC-related closes to produce spurious "log" events in other tests. GC-related closes to produce spurious "log" events in other tests.
** getsockopt no longer risks a buffer overrun with timestamps ** getsockopt no longer risks a buffer overrun with timestamps
(<https://bugs.gnu.org/76907>) (<https://bugs.gnu.org/76907>)
** In MinGW, fix tmpnam returning names in root directory
Changes in 3.0.10 (since 3.0.9) Changes in 3.0.10 (since 3.0.9)
@ -399,6 +400,14 @@ have them. Send any bug reports to bug-guile@gnu.org.
** Hashing of UTF-8 symbols with non-ASCII characters avoids corruption ** Hashing of UTF-8 symbols with non-ASCII characters avoids corruption
(<https://bugs.gnu.org/56413>) (<https://bugs.gnu.org/56413>)
This issue could cause `scm_from_utf8_symbol' and
`scm_from_utf8_symboln` to incorrectly conclude that the symbol hadn't
already been interned, and then create a new one, which of course
wouldn't be `eq?' to the other(s). The incorrect hash was the result of
a buffer overrun, and so might vary. This problem affected a number of
other operations, given the internal use of those functions.
Hearty thanks to Arne Babenhauserheide, Arsen Arsenović, Bruno Victal, Hearty thanks to Arne Babenhauserheide, Arsen Arsenović, Bruno Victal,
Christopher Baines, Daniel Llorens, Denis 'GNUtoo' Carikli, Ekaitz Christopher Baines, Daniel Llorens, Denis 'GNUtoo' Carikli, Ekaitz
Zarraga, Jonas Hahnfeld, Jorge Gomez, Josselin Poiret, Juliana Sims, Zarraga, Jonas Hahnfeld, Jorge Gomez, Josselin Poiret, Juliana Sims,

View file

@ -1799,11 +1799,24 @@ SCM_DEFINE (scm_tmpnam, "tmpnam", 0, 0, 0,
scm_c_issue_deprecation_warning scm_c_issue_deprecation_warning
("Use of tmpnam is deprecated. Use mkstemp instead."); ("Use of tmpnam is deprecated. Use mkstemp instead.");
#ifndef _WIN32
SCM_SYSCALL (rv = tmpnam (name)); SCM_SYSCALL (rv = tmpnam (name));
#else
/* _tempnam properly prepends the temp directory path. */
SCM_SYSCALL (rv = _tempnam (NULL, ""));
#endif
if (rv == NULL) if (rv == NULL)
/* not SCM_SYSERROR since errno probably not set. */ /* not SCM_SYSERROR since errno probably not set. */
SCM_MISC_ERROR ("tmpnam failed", SCM_EOL); SCM_MISC_ERROR ("tmpnam failed", SCM_EOL);
#ifndef _WIN32
return scm_from_locale_string (name); return scm_from_locale_string (name);
#else
SCM ret = scm_from_locale_string (rv);
free (rv);
return ret;
#endif
} }
#undef FUNC_NAME #undef FUNC_NAME

View file

@ -58,6 +58,22 @@
;; (pass-if-exception "./nosuchprog" '(system-error . ".*") ;; (pass-if-exception "./nosuchprog" '(system-error . ".*")
;; (execle "./nosuchprog" '("FOO=1" "BAR=2") "./nosuchprog" "some arg"))) ;; (execle "./nosuchprog" '("FOO=1" "BAR=2") "./nosuchprog" "some arg")))
;;
;; tmpnam
;;
(with-test-prefix "tmpnam"
(pass-if "returns usable location"
(unless (defined? 'tmpnam)
;; tmpnam is deprecated
(throw 'unsupported))
(let* ((filename (tmpnam))
(outport (open-output-file filename)))
(display "\n" outport)
(close-port outport)
(let ((result (access? filename R_OK)))
(delete-file filename)
result))))
;; ;;
;; mkstemp ;; mkstemp