[openssh-commits] [openssh] branch master updated: Include stdlib.h before defining the mkstemp() macro.

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Nov 24 20:30:15 AEDT 2026


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

The following commit(s) were added to refs/heads/master by this push:
     new d1b85c672 Include stdlib.h before defining the mkstemp() macro.
d1b85c672 is described below

commit d1b85c67231443b6db150c56ec5aec0e88459edb
Author: Adam Zegarek <keragez at gmail.com>
AuthorDate: Fri Nov 6 10:00:49 2026 +0000

    Include stdlib.h before defining the mkstemp() macro.
    
    On 32-bit systems with _FILE_OFFSET_BITS=64, glibc's stdlib.h declares
    mkstemp() as an asm redirect to mkstemp64. If stdlib.h is included
    after openbsd-compat.h (as most sources do via includes.h), the
    mkstemp(x) macro rewrites that declaration into
    
        extern int _ssh_mkstemp(char *) __asm__("mkstemp64");
    
    so the _ssh_mkstemp() wrapper is emitted as "mkstemp64", while the
    plain "int mkstemp(char *)" declaration in mktemp.c makes the wrapper
    call the 32-bit off_t mkstemp(). Binaries end up importing
    mkstemp at GLIBC_2.0 despite being built for large files.
    
    Including stdlib.h first lets glibc declare mkstemp() with its
    redirect before the macro exists: callers then use _ssh_mkstemp and
    the wrapper calls mkstemp64.  bz#4064.
---
 openbsd-compat/openbsd-compat.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index 930cf1fa2..f73934706 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -35,6 +35,7 @@
 #include <sys/socket.h>
 
 #include <stddef.h>  /* for wchar_t */
+#include <stdlib.h>  /* must precede the mkstemp() macro below */
 
 /* OpenBSD function replacements */
 #include "base64.h"

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list