summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-04-23 14:42:58 +0200
committerGedare Bloom <gedare@rtems.org>2018-01-11 12:13:32 -0500
commit17fa7d616025cce6845ad00919be5c00a66002ae (patch)
treea3cc45f12fcf5925ec5499144d1b22bf6b0e2c12
parenta078d6f0ab707dd43aac94b029ebf23ab5e92f6a (diff)
librpc: PR2066: Fix for short enums
The XDR library has a problem on architectures with short enums like the default ARM EABI. Short enums means that the size of the enum type is variable and the smallest integer type to hold all enum values will be selected. For many enums this is char. The XDR library uses int32_t for enum_t. There are several evil casts from an enum type to enum_t which leads to invalid memory accesses on short enum architectures. A workaround is to add appropriate dummy enum values.
-rw-r--r--cpukit/librpc/include/rpc/auth.h3
-rw-r--r--cpukit/librpc/include/rpc/clnt_stat.h3
-rw-r--r--cpukit/librpc/include/rpc/rpc_msg.h12
-rw-r--r--cpukit/librpc/include/rpc/svc.h3
-rw-r--r--cpukit/librpc/include/rpcsvc/nis_db.h6
-rw-r--r--cpukit/librpc/include/rpcsvc/yp_prot.h3
-rw-r--r--cpukit/librpc/src/xdr/xdr.c8
7 files changed, 23 insertions, 15 deletions
diff --git a/cpukit/librpc/include/rpc/auth.h b/cpukit/librpc/include/rpc/auth.h
index f644532f3e..8f5273ba5d 100644
--- a/cpukit/librpc/include/rpc/auth.h
+++ b/cpukit/librpc/include/rpc/auth.h
@@ -66,7 +66,8 @@ enum auth_stat {
* failed locally
*/
AUTH_INVALIDRESP=6, /* bogus response verifier */
- AUTH_FAILED=7 /* some unknown reason */
+ AUTH_FAILED=7, /* some unknown reason */
+ _AUTH_STAT = 0xffffffff
};
union des_block {
diff --git a/cpukit/librpc/include/rpc/clnt_stat.h b/cpukit/librpc/include/rpc/clnt_stat.h
index 397bdbc596..2c68745407 100644
--- a/cpukit/librpc/include/rpc/clnt_stat.h
+++ b/cpukit/librpc/include/rpc/clnt_stat.h
@@ -73,7 +73,8 @@ enum clnt_stat {
RPC_STALERACHANDLE = 25,
RPC_CANTCONNECT = 26, /* couldn't make connection (cots) */
RPC_XPRTFAILED = 27, /* received discon from remote (cots) */
- RPC_CANTCREATESTREAM = 28 /* can't push rpc module (cots) */
+ RPC_CANTCREATESTREAM = 28, /* can't push rpc module (cots) */
+ _CLNT_STAT = 0xffffffff
};
#ifdef __cplusplus
diff --git a/cpukit/librpc/include/rpc/rpc_msg.h b/cpukit/librpc/include/rpc/rpc_msg.h
index 21fcb841a1..c2f3304674 100644
--- a/cpukit/librpc/include/rpc/rpc_msg.h
+++ b/cpukit/librpc/include/rpc/rpc_msg.h
@@ -56,12 +56,14 @@
enum msg_type {
CALL=0,
- REPLY=1
+ REPLY=1,
+ _MSG_TYPE = 0xffffffff
};
enum reply_stat {
MSG_ACCEPTED=0,
- MSG_DENIED=1
+ MSG_DENIED=1,
+ _REPLY_STAT = 0xffffffff
};
enum accept_stat {
@@ -70,12 +72,14 @@ enum accept_stat {
PROG_MISMATCH=2,
PROC_UNAVAIL=3,
GARBAGE_ARGS=4,
- SYSTEM_ERR=5
+ SYSTEM_ERR=5,
+ _ACCEPT_STAT = 0xffffffff
};
enum reject_stat {
RPC_MISMATCH=0,
- AUTH_ERROR=1
+ AUTH_ERROR=1,
+ _REJECT_STAT = 0xffffffff
};
/*
diff --git a/cpukit/librpc/include/rpc/svc.h b/cpukit/librpc/include/rpc/svc.h
index f7c6ebd0e5..30fc4f7278 100644
--- a/cpukit/librpc/include/rpc/svc.h
+++ b/cpukit/librpc/include/rpc/svc.h
@@ -66,7 +66,8 @@
enum xprt_stat {
XPRT_DIED,
XPRT_MOREREQS,
- XPRT_IDLE
+ XPRT_IDLE,
+ _XPRT_STAT = 0xffffffff
};
struct rpc_msg;
diff --git a/cpukit/librpc/include/rpcsvc/nis_db.h b/cpukit/librpc/include/rpcsvc/nis_db.h
index dbdee5aac8..71785b0fa8 100644
--- a/cpukit/librpc/include/rpcsvc/nis_db.h
+++ b/cpukit/librpc/include/rpcsvc/nis_db.h
@@ -69,7 +69,8 @@ enum db_status {
DB_BADOBJECT = 5,
DB_MEMORY_LIMIT = 6,
DB_STORAGE_LIMIT = 7,
- DB_INTERNAL_ERROR = 8
+ DB_INTERNAL_ERROR = 8,
+ _DB_STATUS = 0xffffffff
};
typedef enum db_status db_status;
@@ -80,7 +81,8 @@ enum db_action {
DB_FIRST = 3,
DB_NEXT = 4,
DB_ALL = 5,
- DB_RESET_NEXT = 6
+ DB_RESET_NEXT = 6,
+ _DB_ACTION = 0xffffffff
};
typedef enum db_action db_action;
diff --git a/cpukit/librpc/include/rpcsvc/yp_prot.h b/cpukit/librpc/include/rpcsvc/yp_prot.h
index 5abe0e2514..f29f3ce833 100644
--- a/cpukit/librpc/include/rpcsvc/yp_prot.h
+++ b/cpukit/librpc/include/rpcsvc/yp_prot.h
@@ -233,7 +233,8 @@ struct dom_binding {
/* error code in ypbind_resp.ypbind_status */
enum ypbind_resptype {
YPBIND_SUCC_VAL = 1,
- YPBIND_FAIL_VAL = 2
+ YPBIND_FAIL_VAL = 2,
+ _YPBIND_RESPTYPE = 0xffffffff
};
/* network order, of course */
diff --git a/cpukit/librpc/src/xdr/xdr.c b/cpukit/librpc/src/xdr/xdr.c
index 02631e60ef..80c29bbfa5 100644
--- a/cpukit/librpc/src/xdr/xdr.c
+++ b/cpukit/librpc/src/xdr/xdr.c
@@ -458,16 +458,14 @@ xdr_enum(
enum_t *ep)
{
#ifndef lint
- enum sizecheck { SIZEVAL }; /* used to find the size of an enum */
-
/*
* enums are treated as ints
*/
- if (sizeof (enum sizecheck) == sizeof (long)) {
+ if (sizeof (enum_t) == sizeof (long)) {
return (xdr_long(xdrs, (long *)ep));
- } else if (sizeof (enum sizecheck) == sizeof (int)) {
+ } else if (sizeof (enum_t) == sizeof (int)) {
return (xdr_int(xdrs, (int *)ep));
- } else if (sizeof (enum sizecheck) == sizeof (short)) {
+ } else if (sizeof (enum_t) == sizeof (short)) {
return (xdr_short(xdrs, (short *)ep));
} else {
return (FALSE);