Ticket #2066: 0001-librpc-Fix-for-short-enums.patch

File 0001-librpc-Fix-for-short-enums.patch, 5.3 KB (added by Sebastian Huber, on 05/22/12 at 08:05:04)

Patch.

  • cpukit/librpc/include/rpc/auth.h

    From 6631b094db1ebe4be66cd071b607cdfab3bc1129 Mon Sep 17 00:00:00 2001
    From: Sebastian Huber <sebastian.huber@embedded-brains.de>
    Date: Mon, 23 Apr 2012 14:42:58 +0200
    Subject: [PATCH] librpc: 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.
    ---
     cpukit/librpc/include/rpc/auth.h       |    3 ++-
     cpukit/librpc/include/rpc/clnt_stat.h  |    3 ++-
     cpukit/librpc/include/rpc/rpc_msg.h    |   12 ++++++++----
     cpukit/librpc/include/rpc/svc.h        |    3 ++-
     cpukit/librpc/include/rpc/xdr.h        |    3 ++-
     cpukit/librpc/include/rpcsvc/nis_db.h  |    6 ++++--
     cpukit/librpc/include/rpcsvc/yp_prot.h |    3 ++-
     cpukit/librpc/src/xdr/xdr.c            |    8 +++-----
     8 files changed, 25 insertions(+), 16 deletions(-)
    
    diff --git a/cpukit/librpc/include/rpc/auth.h b/cpukit/librpc/include/rpc/auth.h
    index 1b4367c..13432bd 100644
    a b enum auth_stat { 
    6767         * failed locally
    6868        */
    6969        AUTH_INVALIDRESP=6,             /* bogus response verifier */
    70         AUTH_FAILED=7                   /* some unknown reason */
     70        AUTH_FAILED=7,                  /* some unknown reason */
     71        _AUTH_STAT = 0xffffffff
    7172};
    7273
    7374union des_block {
  • cpukit/librpc/include/rpc/clnt_stat.h

    diff --git a/cpukit/librpc/include/rpc/clnt_stat.h b/cpukit/librpc/include/rpc/clnt_stat.h
    index 397bdbc..2c68745 100644
    a b enum clnt_stat { 
    7373        RPC_STALERACHANDLE = 25,
    7474        RPC_CANTCONNECT = 26,           /* couldn't make connection (cots) */
    7575        RPC_XPRTFAILED = 27,            /* received discon from remote (cots) */
    76         RPC_CANTCREATESTREAM = 28       /* can't push rpc module (cots) */
     76        RPC_CANTCREATESTREAM = 28,      /* can't push rpc module (cots) */
     77        _CLNT_STAT = 0xffffffff
    7778};
    7879
    7980#ifdef __cplusplus
  • cpukit/librpc/include/rpc/rpc_msg.h

    diff --git a/cpukit/librpc/include/rpc/rpc_msg.h b/cpukit/librpc/include/rpc/rpc_msg.h
    index 85d2c70..3f5fa51 100644
    a b struct rpc_err; /* forward */ 
    6262
    6363enum msg_type {
    6464        CALL=0,
    65         REPLY=1
     65        REPLY=1,
     66        _MSG_TYPE = 0xffffffff
    6667};
    6768
    6869enum reply_stat {
    6970        MSG_ACCEPTED=0,
    70         MSG_DENIED=1
     71        MSG_DENIED=1,
     72        _REPLY_STAT = 0xffffffff
    7173};
    7274
    7375enum accept_stat {
    enum accept_stat { 
    7678        PROG_MISMATCH=2,
    7779        PROC_UNAVAIL=3,
    7880        GARBAGE_ARGS=4,
    79         SYSTEM_ERR=5
     81        SYSTEM_ERR=5,
     82        _ACCEPT_STAT = 0xffffffff
    8083};
    8184
    8285enum reject_stat {
    8386        RPC_MISMATCH=0,
    84         AUTH_ERROR=1
     87        AUTH_ERROR=1,
     88        _REJECT_STAT = 0xffffffff
    8589};
    8690
    8791/*
  • cpukit/librpc/include/rpc/svc.h

    diff --git a/cpukit/librpc/include/rpc/svc.h b/cpukit/librpc/include/rpc/svc.h
    index 969d2c5..0ef3b8c 100644
    a b  
    7272enum xprt_stat {
    7373        XPRT_DIED,
    7474        XPRT_MOREREQS,
    75         XPRT_IDLE
     75        XPRT_IDLE,
     76        _XPRT_STAT = 0xffffffff
    7677};
    7778
    7879struct rpc_msg;
  • cpukit/librpc/include/rpc/xdr.h

    diff --git a/cpukit/librpc/include/rpc/xdr.h b/cpukit/librpc/include/rpc/xdr.h
    index 30f2bcc..bcdf399 100644
    a b  
    8484enum xdr_op {
    8585        XDR_ENCODE=0,
    8686        XDR_DECODE=1,
    87         XDR_FREE=2
     87        XDR_FREE=2,
     88        _XDR_OP = 0xffffffff
    8889};
    8990
    9091/*
  • cpukit/librpc/include/rpcsvc/nis_db.h

    diff --git a/cpukit/librpc/include/rpcsvc/nis_db.h b/cpukit/librpc/include/rpcsvc/nis_db.h
    index dbdee5a..71785b0 100644
    a b enum db_status { 
    6969        DB_BADOBJECT = 5,
    7070        DB_MEMORY_LIMIT = 6,
    7171        DB_STORAGE_LIMIT = 7,
    72         DB_INTERNAL_ERROR = 8
     72        DB_INTERNAL_ERROR = 8,
     73        _DB_STATUS = 0xffffffff
    7374};
    7475typedef enum db_status db_status;
    7576
    enum db_action { 
    8081        DB_FIRST = 3,
    8182        DB_NEXT = 4,
    8283        DB_ALL = 5,
    83         DB_RESET_NEXT = 6
     84        DB_RESET_NEXT = 6,
     85        _DB_ACTION = 0xffffffff
    8486};
    8587typedef enum db_action db_action;
    8688
  • cpukit/librpc/include/rpcsvc/yp_prot.h

    diff --git a/cpukit/librpc/include/rpcsvc/yp_prot.h b/cpukit/librpc/include/rpcsvc/yp_prot.h
    index 5abe0e2..f29f3ce 100644
    a b struct dom_binding { 
    233233/* error code in ypbind_resp.ypbind_status */
    234234enum ypbind_resptype {
    235235        YPBIND_SUCC_VAL = 1,
    236         YPBIND_FAIL_VAL = 2
     236        YPBIND_FAIL_VAL = 2,
     237        _YPBIND_RESPTYPE = 0xffffffff
    237238};
    238239
    239240/* network order, of course */
  • cpukit/librpc/src/xdr/xdr.c

    diff --git a/cpukit/librpc/src/xdr/xdr.c b/cpukit/librpc/src/xdr/xdr.c
    index 02631e6..80c29bb 100644
    a b xdr_enum( 
    458458        enum_t *ep)
    459459{
    460460#ifndef lint
    461         enum sizecheck { SIZEVAL };     /* used to find the size of an enum */
    462 
    463461        /*
    464462         * enums are treated as ints
    465463         */
    466         if (sizeof (enum sizecheck) == sizeof (long)) {
     464        if (sizeof (enum_t) == sizeof (long)) {
    467465                return (xdr_long(xdrs, (long *)ep));
    468         } else if (sizeof (enum sizecheck) == sizeof (int)) {
     466        } else if (sizeof (enum_t) == sizeof (int)) {
    469467                return (xdr_int(xdrs, (int *)ep));
    470         } else if (sizeof (enum sizecheck) == sizeof (short)) {
     468        } else if (sizeof (enum_t) == sizeof (short)) {
    471469                return (xdr_short(xdrs, (short *)ep));
    472470        } else {
    473471                return (FALSE);