diff options
author | Simo Sorce <simo@redhat.com> | 2012-03-21 19:11:10 -0400 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2012-03-22 02:33:52 -0400 |
commit | 403119d7f4d4070bfd8f7fb796729127666e2e11 (patch) | |
tree | 9f272395031e3a5bfd03fab65da2a2dde439b276 /proxy/src/gp_socket.c | |
parent | 9714cbbf07093e7b6661d8fb93c0b00172d3d677 (diff) | |
download | gss-proxy-403119d7f4d4070bfd8f7fb796729127666e2e11.tar.gz gss-proxy-403119d7f4d4070bfd8f7fb796729127666e2e11.tar.xz gss-proxy-403119d7f4d4070bfd8f7fb796729127666e2e11.zip |
gp_socket: properly handle fagment bit
Diffstat (limited to 'proxy/src/gp_socket.c')
-rw-r--r-- | proxy/src/gp_socket.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/proxy/src/gp_socket.c b/proxy/src/gp_socket.c index a8d3a55..233633b 100644 --- a/proxy/src/gp_socket.c +++ b/proxy/src/gp_socket.c @@ -47,6 +47,8 @@ struct gp_creds { #endif }; +#define FRAGMENT_BIT (1 << 31) + struct unix_sock_conn { int sd; @@ -259,6 +261,17 @@ static void gp_socket_read(verto_ctx *vctx, verto_ev *ev) /* allocate buffer for receiving data */ rbuf->size = ntohl(size); + + /* FIXME: need to support multiple fragments */ + /* for now just make sure we have the last fragment bit + * then remove it */ + if (rbuf->size & FRAGMENT_BIT) { + rbuf->size &= ~FRAGMENT_BIT; + } else { + ret = EIO; + goto done; + } + if (rbuf->size > MAX_RPC_SIZE) { /* req too big close conn. */ ret = EIO; @@ -375,7 +388,8 @@ static void gp_socket_write(verto_ctx *vctx, verto_ev *ev) if (wbuf->pos == 0) { /* first write, send the buffer size as packet header */ - size = htonl(wbuf->size); + size = wbuf->size | FRAGMENT_BIT; + size = htonl(size); iov[0].iov_base = &size; iov[0].iov_len = sizeof(size); |