summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-03-21 19:11:10 -0400
committerSimo Sorce <simo@redhat.com>2012-03-22 02:33:52 -0400
commit403119d7f4d4070bfd8f7fb796729127666e2e11 (patch)
tree9f272395031e3a5bfd03fab65da2a2dde439b276
parent9714cbbf07093e7b6661d8fb93c0b00172d3d677 (diff)
downloadgss-proxy-403119d7f4d4070bfd8f7fb796729127666e2e11.tar.gz
gss-proxy-403119d7f4d4070bfd8f7fb796729127666e2e11.tar.xz
gss-proxy-403119d7f4d4070bfd8f7fb796729127666e2e11.zip
gp_socket: properly handle fagment bit
-rw-r--r--proxy/src/gp_socket.c16
-rw-r--r--proxy/src/mechglue/gpm_common.c6
2 files changed, 20 insertions, 2 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);
diff --git a/proxy/src/mechglue/gpm_common.c b/proxy/src/mechglue/gpm_common.c
index 5c20778..22b3449 100644
--- a/proxy/src/mechglue/gpm_common.c
+++ b/proxy/src/mechglue/gpm_common.c
@@ -30,6 +30,8 @@
#include <time.h>
#include <pthread.h>
+#define FRAGMENT_BIT (1 << 31)
+
struct gpm_ctx {
pthread_mutex_t lock;
int fd;
@@ -168,7 +170,8 @@ static int gpm_send_buffer(struct gpm_ctx *gpmctx,
gpm_grab_sock(gpmctx);
- size = htonl(length);
+ size = length | FRAGMENT_BIT;
+ size = htonl(size);
retry = false;
do {
@@ -258,6 +261,7 @@ static int gpm_recv_buffer(struct gpm_ctx *gpmctx,
} while (retry);
*length = ntohl(size);
+ *length &= ~FRAGMENT_BIT;
if (*length > MAX_RPC_SIZE) {
ret = EMSGSIZE;