From 8d4335cb9be89a0813640b54b89d23507be8c423 Mon Sep 17 00:00:00 2001 From: guenther Date: Mon, 14 Feb 2022 03:38:59 +0000 Subject: [PATCH] Mark all the rpc 'ops' vectors, for auth, client, service, and xdr, as const, moving them from .data to .data.rel.ro. The other BSDs did this a long time ago; NetBSD did a chunk in 1998, which is long enough I didn't bother to get exact dates for others. ok deraadt@ millert@ --- include/rpc/auth.h | 4 ++-- include/rpc/clnt.h | 4 ++-- include/rpc/svc.h | 4 ++-- include/rpc/xdr.h | 4 ++-- lib/libc/rpc/auth_none.c | 4 ++-- lib/libc/rpc/auth_unix.c | 4 ++-- lib/libc/rpc/clnt_raw.c | 4 ++-- lib/libc/rpc/clnt_tcp.c | 4 ++-- lib/libc/rpc/clnt_udp.c | 4 ++-- lib/libc/rpc/svc_raw.c | 4 ++-- lib/libc/rpc/svc_tcp.c | 6 +++--- lib/libc/rpc/svc_udp.c | 4 ++-- lib/libc/rpc/xdr_mem.c | 6 +++--- lib/libc/rpc/xdr_rec.c | 4 ++-- lib/libc/rpc/xdr_stdio.c | 4 ++-- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/rpc/auth.h b/include/rpc/auth.h index 1cd94bb7a88..3442082967d 100644 --- a/include/rpc/auth.h +++ b/include/rpc/auth.h @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.h,v 1.8 2015/09/13 12:29:03 guenther Exp $ */ +/* $OpenBSD: auth.h,v 1.9 2022/02/14 03:38:59 guenther Exp $ */ /* $NetBSD: auth.h,v 1.7 1995/04/29 05:27:55 cgd Exp $ */ /* @@ -101,7 +101,7 @@ typedef struct __rpc_auth { struct opaque_auth ah_cred; struct opaque_auth ah_verf; union des_block ah_key; - struct auth_ops { + const struct auth_ops { void (*ah_nextverf)(struct __rpc_auth *); /* nextverf & serialize */ int (*ah_marshal)(struct __rpc_auth *, XDR *); diff --git a/include/rpc/clnt.h b/include/rpc/clnt.h index e5a62e3cb25..3c21ef19bc1 100644 --- a/include/rpc/clnt.h +++ b/include/rpc/clnt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clnt.h,v 1.11 2010/09/01 14:43:34 millert Exp $ */ +/* $OpenBSD: clnt.h,v 1.12 2022/02/14 03:38:59 guenther Exp $ */ /* $NetBSD: clnt.h,v 1.6 1995/04/29 05:27:58 cgd Exp $ */ /* @@ -118,7 +118,7 @@ struct rpc_err { */ typedef struct __rpc_client { AUTH *cl_auth; /* authenticator */ - struct clnt_ops { + const struct clnt_ops { /* call remote procedure */ enum clnt_stat (*cl_call)(struct __rpc_client *, unsigned long, xdrproc_t, caddr_t, diff --git a/include/rpc/svc.h b/include/rpc/svc.h index 7402420a07c..ae7ae904b20 100644 --- a/include/rpc/svc.h +++ b/include/rpc/svc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: svc.h,v 1.16 2016/08/27 04:28:28 guenther Exp $ */ +/* $OpenBSD: svc.h,v 1.17 2022/02/14 03:38:59 guenther Exp $ */ /* $NetBSD: svc.h,v 1.9 1995/04/29 05:28:01 cgd Exp $ */ /* @@ -78,7 +78,7 @@ enum xprt_stat { typedef struct __rpc_svcxprt { int xp_sock; unsigned short xp_port; /* associated port number */ - struct xp_ops { + const struct xp_ops { /* receive incoming requests */ bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h index 1f0532a1191..126ecec54f9 100644 --- a/include/rpc/xdr.h +++ b/include/rpc/xdr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xdr.h,v 1.12 2010/09/01 14:43:34 millert Exp $ */ +/* $OpenBSD: xdr.h,v 1.13 2022/02/14 03:38:59 guenther Exp $ */ /* $NetBSD: xdr.h,v 1.7 1995/04/29 05:28:06 cgd Exp $ */ /* @@ -99,7 +99,7 @@ enum xdr_op { */ typedef struct __rpc_xdr { enum xdr_op x_op; /* operation; fast additional param */ - struct xdr_ops { + const struct xdr_ops { /* get a long from underlying stream */ bool_t (*x_getlong)(struct __rpc_xdr *, long *); /* put a long to " */ diff --git a/lib/libc/rpc/auth_none.c b/lib/libc/rpc/auth_none.c index 8ba7b71da27..b9bd8083596 100644 --- a/lib/libc/rpc/auth_none.c +++ b/lib/libc/rpc/auth_none.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth_none.c,v 1.14 2015/11/01 03:45:29 guenther Exp $ */ +/* $OpenBSD: auth_none.c,v 1.15 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -53,7 +53,7 @@ static bool_t authnone_validate(struct __rpc_auth *, struct opaque_auth *); static bool_t authnone_marshal(struct __rpc_auth *, XDR *); static bool_t authnone_refresh(struct __rpc_auth *); -static struct auth_ops ops = { +static const struct auth_ops ops = { authnone_verf, authnone_marshal, authnone_validate, diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index e1288dc6fc7..32ead395d0f 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth_unix.c,v 1.29 2022/01/28 05:54:02 guenther Exp $ */ +/* $OpenBSD: auth_unix.c,v 1.30 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -61,7 +61,7 @@ static bool_t authunix_validate(struct __rpc_auth *, struct opaque_auth *); static bool_t authunix_refresh(struct __rpc_auth *); static void authunix_destroy(struct __rpc_auth *); -static struct auth_ops auth_unix_ops = { +static const struct auth_ops auth_unix_ops = { authunix_nextverf, authunix_marshal, authunix_validate, diff --git a/lib/libc/rpc/clnt_raw.c b/lib/libc/rpc/clnt_raw.c index 92076ba97d7..59eb0f810a9 100644 --- a/lib/libc/rpc/clnt_raw.c +++ b/lib/libc/rpc/clnt_raw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clnt_raw.c,v 1.20 2015/11/01 03:45:29 guenther Exp $ */ +/* $OpenBSD: clnt_raw.c,v 1.21 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -66,7 +66,7 @@ static bool_t clntraw_freeres(CLIENT *, xdrproc_t, caddr_t); static bool_t clntraw_control(CLIENT *, u_int, void *); static void clntraw_destroy(CLIENT *); -static struct clnt_ops client_ops = { +static const struct clnt_ops client_ops = { clntraw_call, clntraw_abort, clntraw_geterr, diff --git a/lib/libc/rpc/clnt_tcp.c b/lib/libc/rpc/clnt_tcp.c index b9c3191f514..f1b4d9c0fcd 100644 --- a/lib/libc/rpc/clnt_tcp.c +++ b/lib/libc/rpc/clnt_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clnt_tcp.c,v 1.34 2020/07/06 13:33:06 pirofti Exp $ */ +/* $OpenBSD: clnt_tcp.c,v 1.35 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -68,7 +68,7 @@ static bool_t clnttcp_freeres(CLIENT *, xdrproc_t, caddr_t); static bool_t clnttcp_control(CLIENT *, u_int, void *); static void clnttcp_destroy(CLIENT *); -static struct clnt_ops tcp_ops = { +static const struct clnt_ops tcp_ops = { clnttcp_call, clnttcp_abort, clnttcp_geterr, diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c index 196583423e7..56443a932b4 100644 --- a/lib/libc/rpc/clnt_udp.c +++ b/lib/libc/rpc/clnt_udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clnt_udp.c,v 1.37 2020/07/06 13:33:06 pirofti Exp $ */ +/* $OpenBSD: clnt_udp.c,v 1.38 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -57,7 +57,7 @@ static bool_t clntudp_freeres(CLIENT *, xdrproc_t, caddr_t); static bool_t clntudp_control(CLIENT *, u_int, void *); static void clntudp_destroy(CLIENT *); -static struct clnt_ops udp_ops = { +static const struct clnt_ops udp_ops = { clntudp_call, clntudp_abort, clntudp_geterr, diff --git a/lib/libc/rpc/svc_raw.c b/lib/libc/rpc/svc_raw.c index d573440e6bd..cfef6fd069f 100644 --- a/lib/libc/rpc/svc_raw.c +++ b/lib/libc/rpc/svc_raw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svc_raw.c,v 1.12 2015/11/01 03:45:29 guenther Exp $ */ +/* $OpenBSD: svc_raw.c,v 1.13 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -61,7 +61,7 @@ static bool_t svcraw_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr); static void svcraw_destroy(SVCXPRT *xprt); -static struct xp_ops server_ops = { +static const struct xp_ops server_ops = { svcraw_recv, svcraw_stat, svcraw_getargs, diff --git a/lib/libc/rpc/svc_tcp.c b/lib/libc/rpc/svc_tcp.c index d1501770e14..9dbd44abe3a 100644 --- a/lib/libc/rpc/svc_tcp.c +++ b/lib/libc/rpc/svc_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svc_tcp.c,v 1.41 2020/07/06 13:33:06 pirofti Exp $ */ +/* $OpenBSD: svc_tcp.c,v 1.42 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -63,7 +63,7 @@ static bool_t svctcp_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr); static void svctcp_destroy(SVCXPRT *xprt); -static struct xp_ops svctcp_op = { +static const struct xp_ops svctcp_op = { svctcp_recv, svctcp_stat, svctcp_getargs, @@ -78,7 +78,7 @@ static struct xp_ops svctcp_op = { static bool_t rendezvous_request(SVCXPRT *xprt, struct rpc_msg *); static enum xprt_stat rendezvous_stat(SVCXPRT *xprt); -static struct xp_ops svctcp_rendezvous_op = { +static const struct xp_ops svctcp_rendezvous_op = { rendezvous_request, rendezvous_stat, /* XXX abort illegal in library */ diff --git a/lib/libc/rpc/svc_udp.c b/lib/libc/rpc/svc_udp.c index ccd00f3c4ab..7966d256bf9 100644 --- a/lib/libc/rpc/svc_udp.c +++ b/lib/libc/rpc/svc_udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svc_udp.c,v 1.26 2019/06/28 13:32:42 deraadt Exp $ */ +/* $OpenBSD: svc_udp.c,v 1.27 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -60,7 +60,7 @@ static void cache_set(SVCXPRT *, u_long); static int cache_get(SVCXPRT *, struct rpc_msg *, char **, u_long *); -static struct xp_ops svcudp_op = { +static const struct xp_ops svcudp_op = { svcudp_recv, svcudp_stat, svcudp_getargs, diff --git a/lib/libc/rpc/xdr_mem.c b/lib/libc/rpc/xdr_mem.c index c82642c8de7..fef897e81e9 100644 --- a/lib/libc/rpc/xdr_mem.c +++ b/lib/libc/rpc/xdr_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xdr_mem.c,v 1.17 2015/11/01 03:45:29 guenther Exp $ */ +/* $OpenBSD: xdr_mem.c,v 1.18 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -59,7 +59,7 @@ static int32_t *xdrmem_inline_aligned(XDR *, u_int); static int32_t *xdrmem_inline_unaligned(XDR *, u_int); static void xdrmem_destroy(XDR *); -static struct xdr_ops xdrmem_ops_aligned = { +static const struct xdr_ops xdrmem_ops_aligned = { xdrmem_getlong_aligned, xdrmem_putlong_aligned, xdrmem_getbytes, @@ -71,7 +71,7 @@ static struct xdr_ops xdrmem_ops_aligned = { NULL, /* xdrmem_control */ }; -static struct xdr_ops xdrmem_ops_unaligned = { +static const struct xdr_ops xdrmem_ops_unaligned = { xdrmem_getlong_unaligned, xdrmem_putlong_unaligned, xdrmem_getbytes, diff --git a/lib/libc/rpc/xdr_rec.c b/lib/libc/rpc/xdr_rec.c index 8feeb0d3468..0af0d9570df 100644 --- a/lib/libc/rpc/xdr_rec.c +++ b/lib/libc/rpc/xdr_rec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xdr_rec.c,v 1.22 2016/09/21 04:38:56 guenther Exp $ */ +/* $OpenBSD: xdr_rec.c,v 1.23 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -80,7 +80,7 @@ PROTO_NORMAL(__xdrrec_getrec); struct ct_data; -static struct xdr_ops xdrrec_ops = { +static const struct xdr_ops xdrrec_ops = { xdrrec_getlong, xdrrec_putlong, xdrrec_getbytes, diff --git a/lib/libc/rpc/xdr_stdio.c b/lib/libc/rpc/xdr_stdio.c index d010a8a4e53..692dcf99a1b 100644 --- a/lib/libc/rpc/xdr_stdio.c +++ b/lib/libc/rpc/xdr_stdio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xdr_stdio.c,v 1.15 2019/06/28 13:32:42 deraadt Exp $ */ +/* $OpenBSD: xdr_stdio.c,v 1.16 2022/02/14 03:38:59 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -55,7 +55,7 @@ static void xdrstdio_destroy(XDR *); /* * Ops vector for stdio type XDR */ -static struct xdr_ops xdrstdio_ops = { +static const struct xdr_ops xdrstdio_ops = { xdrstdio_getlong, /* deserialize a long int */ xdrstdio_putlong, /* serialize a long int */ xdrstdio_getbytes, /* deserialize counted bytes */ -- 2.20.1