<pre style='margin:0'>
Christopher Nielsen (mascguy) pushed a commit to branch master
in repository macports-legacy-support.

</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/46a30685834f0f680cc90dda87dc7933d7c17c49">https://github.com/macports/macports-legacy-support/commit/46a30685834f0f680cc90dda87dc7933d7c17c49</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 46a30685834f0f680cc90dda87dc7933d7c17c49
</span>Author: Fred Wright <fw@fwright.net>
AuthorDate: Thu Nov 7 15:16:24 2024 -0800

<span style='display:block; white-space:pre;color:#404040;'>    realpath: Fix 10.6 non-POSIX version.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    This adds our allocating wrapper to the 10.6 non-POSIX case, which
</span><span style='display:block; white-space:pre;color:#404040;'>    returns an unsafe buffer pointer when supplied with a nonexistent path
</span><span style='display:block; white-space:pre;color:#404040;'>    and no buffer.  Providing our own malloc()ed buffer avoids the
</span><span style='display:block; white-space:pre;color:#404040;'>    problem.  This only affects 32-bit builds, since 64-bit non-POSIX is
</span><span style='display:block; white-space:pre;color:#404040;'>    nonexistent.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    The original flag is renamed in the process, with the original name
</span><span style='display:block; white-space:pre;color:#404040;'>    now reflecting the combined need for the wrapper.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Some whitespace cleanup is also applied to the other composite flag
</span><span style='display:block; white-space:pre;color:#404040;'>    definitions.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Updates README to reflect the fix.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    TESTED:
</span><span style='display:block; white-space:pre;color:#404040;'>    Tests pass on all platforms, including newly added test case (next
</span><span style='display:block; white-space:pre;color:#404040;'>    commit).
</span>---
 README.md                       | 13 ++++++++++---
 include/MacportsLegacySupport.h | 24 +++++++++++++++++++-----
 src/add_symbols.c               |  2 +-
 src/realpath.c                  | 21 +++++++++++++++++++--
 test/test_realpath_compat.c     |  6 +++---
 5 files changed, 52 insertions(+), 14 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/README.md b/README.md
</span><span style='display:block; white-space:pre;color:#808080;'>index 29e6b7b..6b50981 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/README.md
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/README.md
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -75,11 +75,18 @@ Wrapped headers and replaced functions are:
</span>     <td>OSX10.6, OSX10.12 (open_memstream)</td>
   </tr>
   <tr>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    <td rowspan="2"><code>stdlib.h</code></td>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    <td>Adds <code>posix_memalign</code> functional replacement, and wraps <code>realpath</code>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-        to accept a <code>NULL</code> buffer argument</td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    <td rowspan="4"><code>stdlib.h</code></td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    <td>Adds <code>posix_memalign</code> functional replacement</td>
</span>     <td>OSX10.5</td>
   </tr>
<span style='display:block; white-space:pre;background:#e0ffe0;'>+  <tr>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    <td>Wraps <code>realpath</code> to accept a <code>NULL</code> buffer argument</td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    <td>OSX10.5</td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+  </tr>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+  <tr>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    <td>Fixes non-POSIX <code>realpath</code> in 10.6</td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    <td>OSX10.6</td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+  </tr>
</span>   <tr>
     <td>Adds <code>arc4random_uniform</code> and <code>arc4random_buf</code> functions</td>
     <td>OSX10.6</td>
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/MacportsLegacySupport.h b/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;color:#808080;'>index 9ac8b2e..cdb6c50 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -230,7 +230,13 @@
</span> /* The addition uses an #ifndef, so no feature flag is necessary */
 
 /*  realpath() on < 10.6 does not support modern NULL buffer usage */
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#define __MPLS_LIB_SUPPORT_REALPATH_WRAP__    (__MPLS_TARGET_OSVER < 1060)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_LIB_SUPPORT_REALPATH_ALLOC__   (__MPLS_TARGET_OSVER < 1060)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Also, 10.6 non-POSIX realpath() (32-bit only) with a nonexistent path and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * a NULL buffer returns an unsafe pointer to an internal buffer. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_LIB_SUPPORT_REALPATH_NONEX_FIX__ (__MPLS_TARGET_OSVER >= 1060 \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                                 && __MPLS_TARGET_OSVER < 1070 \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                                 && !__MPLS_64BIT)
</span> 
 /* fsetattrlistat, fgetattrlistat */
 #define __MPLS_SDK_SUPPORT_FSETATTRLIST__     (__MPLS_SDK_MAJOR < 1060)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -316,10 +322,18 @@
</span> #define __MPLS_LIB_SUPPORT_PTHREAD_SETNAME_NP__   (__MPLS_TARGET_OSVER < 1060)
 
 /* Compound macros, bundling functionality needed by multiple single features. */
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#define __MPLS_SDK_NEED_ATCALL_MACROS__  (__MPLS_SDK_SUPPORT_ATCALLS__ || __MPLS_SDK_SUPPORT_SETATTRLISTAT__)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define __MPLS_SDK_NEED_BEST_FCHDIR__    (__MPLS_SDK_SUPPORT_FDOPENDIR__ || __MPLS_SDK_SUPPORT_ATCALLS__ || __MPLS_SDK_SUPPORT_SETATTRLISTAT__)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define __MPLS_LIB_NEED_BEST_FCHDIR__    (__MPLS_LIB_SUPPORT_FDOPENDIR__ || __MPLS_LIB_SUPPORT_ATCALLS__ || __MPLS_LIB_SUPPORT_SETATTRLISTAT__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_SDK_NEED_ATCALL_MACROS__  (__MPLS_SDK_SUPPORT_ATCALLS__ \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                          || __MPLS_SDK_SUPPORT_SETATTRLISTAT__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_SDK_NEED_BEST_FCHDIR__    (__MPLS_SDK_SUPPORT_FDOPENDIR__ \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                          || __MPLS_SDK_SUPPORT_ATCALLS__ \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                          || __MPLS_SDK_SUPPORT_SETATTRLISTAT__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_LIB_NEED_BEST_FCHDIR__    (__MPLS_LIB_SUPPORT_FDOPENDIR__ \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                          || __MPLS_LIB_SUPPORT_ATCALLS__ \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                          || __MPLS_LIB_SUPPORT_SETATTRLISTAT__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_LIB_SUPPORT_REALPATH_WRAP__ (__MPLS_LIB_SUPPORT_REALPATH_ALLOC__ \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                            || __MPLS_LIB_SUPPORT_REALPATH_NONEX_FIX__)
</span> 
 /* UUIDs - for now, just add missing typedef statements */
 #define __MPLS_SDK_SUPPORT_UUID__  (__MPLS_SDK_MAJOR < 1060)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/add_symbols.c b/src/add_symbols.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 2243728..7f132fe 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/add_symbols.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/add_symbols.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -5,7 +5,7 @@ extern const char posix_memalign_tmp4 __asm("$ld$add$os10.4$_posix_memalign"); _
</span> extern const char posix_memalign_tmp5 __asm("$ld$add$os10.5$_posix_memalign"); __attribute__((visibility("default"))) const char posix_memalign_tmp5 = 0;
 #endif
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#if !(__MPLS_LIB_SUPPORT_REALPATH_WRAP__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if !(__MPLS_LIB_SUPPORT_REALPATH_ALLOC__)
</span> extern const char realpath_tmp4 __asm("$ld$add$os10.4$_realpath"); __attribute__((visibility("default"))) const char realpath_tmp4 = 0;
 extern const char realpath_tmp5 __asm("$ld$add$os10.5$_realpath$DARWIN_EXTSN"); __attribute__((visibility("default"))) const char realpath_tmp5 = 0;
 #endif
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/realpath.c b/src/realpath.c
</span><span style='display:block; white-space:pre;color:#808080;'>index dc48fa0..3e79005 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/realpath.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/realpath.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -54,8 +54,13 @@
</span> /* Function type for realpath() */
 typedef char *rp_func_t(const char * __restrict, char * __restrict);
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Macro defining all versions */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Note that the UNIX2003 version never exists in 64-bit builds. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Macro defining all versions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Note that the UNIX2003 version never exists in 64-bit builds.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Also note that the 10.6 "nonext" fix only needs the basic version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# if __MPLS_LIB_SUPPORT_REALPATH_ALLOC__
</span> 
 #if !__MPLS_64BIT
 
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -72,6 +77,14 @@ typedef char *rp_func_t(const char * __restrict, char * __restrict);
</span> 
 #endif /* 64-bit */
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MPLS_LIB_SUPPORT_REALPATH_ALLOC__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MPLS_LIB_SUPPORT_REALPATH_NONEX_FIX__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define RP_ALL RP_ENT(,,basic)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MPLS_LIB_SUPPORT_REALPATH_NONEX_FIX__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> /* Table of indices of versions */
 #define RP_ENT(d,x,t) rp_##t,
 typedef enum {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -140,6 +153,8 @@ realpath##d##x(const char * __restrict file_name, \
</span> RP_ALL
 #undef RP_ENT
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# if __MPLS_LIB_SUPPORT_REALPATH_ALLOC__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> /*
  * Compatibility function to avoid the need to rebuild existing binaries
  * built with the old wrapper-macro implementation (between Jan-2019 and
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -162,4 +177,6 @@ macports_legacy_realpath(const char * __restrict file_name,
</span>   return realpath_internal(file_name, resolved_name, RP_DEFAULT);
 }
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MPLS_LIB_SUPPORT_REALPATH_ALLOC__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> #endif /*__MPLS_LIB_SUPPORT_REALPATH_WRAP__*/
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/test/test_realpath_compat.c b/test/test_realpath_compat.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 8158758..d9a890f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/test/test_realpath_compat.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/test/test_realpath_compat.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -12,14 +12,14 @@
</span> 
 /* MP support header */
 #include "MacportsLegacySupport.h"
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#if __MPLS_LIB_SUPPORT_REALPATH_WRAP__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MPLS_LIB_SUPPORT_REALPATH_ALLOC__
</span> 
 #define TEST_MACPORTS_LEGACY_REALPATH
 
 #include "test_realpath.c"
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#else /* !__MPLS_LIB_SUPPORT_REALPATH_WRAP__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#else /* !__MPLS_LIB_SUPPORT_REALPATH_ALLOC__ */
</span> 
 int main(){ return 0; }
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif /* !__MPLS_LIB_SUPPORT_REALPATH_WRAP__ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* !__MPLS_LIB_SUPPORT_REALPATH_ALLOC__ */
</span></pre><pre style='margin:0'>

</pre>