Skip to content

Deprecate non-thread-safe tmpnam #5211

Description

@tgross35

Now that we get linker warnings, the following shows up:

warning: linker stderr: /usr/lib/gcc-cross/s390x-linux-gnu/14/../../../../s390x-linux-gnu/bin/ld: /checkout/target/s390x-unknown-linux-gnu/debug/deps/ctest-2b4e214b33ebd228.6vgf36pq173k6xsd10a2clvaj.0hetexw.rcgu.o: in function `ctest::generated_tests::ctest_foreign_fn_tmpnam':
         /checkout/target/s390x-unknown-linux-gnu/debug/build/libc-test-cd93a2bf0f73e50d/out/ctest_output.rs:216053:(.text._RNvNtCsdHcC3tdE9G5_5ctest15generated_tests23ctest_foreign_fn_tmpnam+0x18): the use of `tmpnam' is dangerous, better use `mkstemp'
  |
  = note: `#[warn(linker_messages)]` on by default
  = note: the `linker_messages` lint ignores `-D warnings`
warning: linker stdout: /usr/lib/gcc-cross/s390x-linux-gnu/14/../../../../s390x-linux-gnu/bin/ld: /checkout/target/s390x-unknown-linux-gnu/debug/deps/ctest-2b4e214b33ebd228.6vgf36pq173k6xsd10a2clvaj.0hetexw.rcgu.o: note: the message above does not take linker garbage collection into account

These are deprecated in glibc at least https://man7.org/linux/man-pages/man3/tmpnam.3.html. We should deprecate all instances of tmpnam, tempnam, and L_tmpnam since they have more secure alternatives, for removal in 1.0.

Activity

  1. added this to the 1.0 milestone on Jun 24, 2026
  2. tgross35 commented on Jun 25, 2026

    @tgross35
    MemberAuthor

    Cc @dybucc as you have been doing a number of deprecations

  3. dybucc commented on Jun 25, 2026

    @dybucc
    Contributor

    Do you mean to deprecate symbols that are deprecated upstream only? Or do you want to also deprecate symbols not recommended for use? Add mktemp in the latter case [1].

  4. tgross35 commented on Jun 25, 2026

    @tgross35
    MemberAuthor

    Just the ones that are deprecated upstream, so we can remove them. There are quite a few bits of API that are no longer recommended but we probably should keep around, mktemp being one of them - maybe we'll deprecate them one day but that's something that can wait until any time after 1.0.

  5. mansiverma897993 commented on Jun 27, 2026

    @mansiverma897993

    @tgross35 can you assign this issue to me ?? I would like to work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions