diff options
author | Matthew N. Dodd <matthew.nygard.dodd@gmail.com> | 2011-06-20 13:33:35 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2011-06-20 13:33:35 -0400 |
commit | 6f4c0348695b56d7ed8880e79ffebddf18a6d1bb (patch) | |
tree | 7e82aa3645bd0efdf329fb85d67c55be503b3825 | |
parent | eb58550c704a2aaa7363141c24bf2c31ebb2c2b9 (diff) | |
download | ti-rpc-6f4c0348695b56d7ed8880e79ffebddf18a6d1bb.tar.gz |
Use of lseek() in xdr_rec.c:xdrrec_getpos().
The use of lseek() in xdr_rec.c:xdrrec_getpos() without checking for
ESPIPE will fail to handle the common case, resulting in poor behavior
in calling code. (In particular auth_gss.c:authgss_marshal() calls
gss_get_mic() with rpcbuf.length set to -1, with spectacular results.)
The original MIT Krb5 RPC code lacks this addition, which I'm unclear of
the utility of in the first place.
Reverting to the MIT code permits correct function of a trivial RPC
client using GSS.
Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | src/xdr_rec.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/xdr_rec.c b/src/xdr_rec.c index 4e815d7..2aca623 100644 --- a/src/xdr_rec.c +++ b/src/xdr_rec.c @@ -64,7 +64,6 @@ #include <rpc/clnt.h> #include <stddef.h> #include "rpc_com.h" -#include <unistd.h> static bool_t xdrrec_getlong(XDR *, long *); static bool_t xdrrec_putlong(XDR *, const long *); static bool_t xdrrec_getbytes(XDR *, char *, u_int); @@ -330,22 +329,22 @@ xdrrec_getpos(xdrs) RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; off_t pos; - pos = lseek((int)(u_long)rstrm->tcp_handle, (off_t)0, 1); - if (pos != -1) - switch (xdrs->x_op) { + switch (xdrs->x_op) { - case XDR_ENCODE: - pos += rstrm->out_finger - rstrm->out_base; - break; + case XDR_ENCODE: + pos = rstrm->out_finger - rstrm->out_base + - BYTES_PER_XDR_UNIT; + break; - case XDR_DECODE: - pos -= rstrm->in_boundry - rstrm->in_finger; - break; + case XDR_DECODE: + pos = rstrm->in_boundry - rstrm->in_finger + - BYTES_PER_XDR_UNIT; + break; - default: - pos = (off_t) -1; - break; - } + default: + pos = (off_t) -1; + break; + } return ((u_int) pos); } |