libtirpc: Use a non-variadic xdrproc_t on Apple platforms
Subsystems (2)
PATCH 1/1 libtirpc: Use a non-variadic xdrproc_t on Apple platforms
xdrproc_t is declared as bool_t (*)(XDR *, ...), but the xdr routines called through it are ordinary non-variadic functions. That does not work on Apple arm64, where variadic arguments are passed on the stack while the xdr routines read their second argument from a register. Every RPC reply goes through such a call in xdr_union(), so an RPC server built on libtirpc cannot send any reply there.
Apple's own rpc/xdr.h in the macOS SDK says about this prototype:
This prototype is incorrect. One may not use a varargs function pointer in place of pointer to a function with positional parameters.
All calls through xdrproc_t in libtirpc pass exactly two arguments, so use a two-argument prototype on Apple platforms. Other platforms are unchanged. The hand-written variadic prototype of svcauth_none_wrap() has to follow.
resultproc_t has the same problem, but its callers pass different numbers of arguments, so it is left alone here.
--- src/svc_auth_none.c | 2 +- tirpc/rpc/xdr.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
src/svc_auth_none.c +1 -1
@@ -38,7 +38,7 @@#include <rpc/rpc.h> static bool_t svcauth_none_destroy (SVCAUTH *); -static bool_t svcauth_none_wrap (SVCAUTH *,XDR *,bool_t (*)(XDR *, ...),char *); +static bool_t svcauth_none_wrap (SVCAUTH *,XDR *,xdrproc_t ,char *);struct svc_auth_ops svc_auth_none_ops = { svcauth_none_wrap,
tirpc/rpc/xdr.h +3 -0
@@ -136,6 +136,9 @@ typedef struct __rpc_xdr {*/ #ifdef _KERNELtypedef bool_t (*xdrproc_t )(XDR *,void *,u_int ); +#elif defined(__APPLE__) +/* See the note on xdrproc_t in Apple's rpc/xdr.h */ +typedef bool_t (*xdrproc_t )(XDR *,void *);#else /* * XXX can't actually prototype it, because some take three args!!!
Signature · 1 line
2.56.0