From 973b2b635f3de9ae9cd3a79872cb5f70b9745760 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Fri, 27 Apr 2007 23:27:31 +0000 Subject: [PATCH] Move the code for queueing an outgoing response on a TCP stream into a separate function. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19535 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kdc/network.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/kdc/network.c b/src/kdc/network.c index e73352fda..20a0bd50c 100644 --- a/src/kdc/network.c +++ b/src/kdc/network.c @@ -1224,6 +1224,17 @@ make_toolong_error (krb5_data **out) return 0; } +static void +queue_tcp_outgoing_response(struct connection *conn) +{ + store_32_be(conn->u.tcp.response->length, conn->u.tcp.lenbuf); + SG_SET(&conn->u.tcp.sgbuf[1], conn->u.tcp.response->data, + conn->u.tcp.response->length); + conn->u.tcp.sgp = conn->u.tcp.sgbuf; + conn->u.tcp.sgnum = 2; + FD_SET(conn->fd, &sstate.wfds); +} + static void process_tcp_connection(struct connection *conn, const char *prog, int selflags) { @@ -1284,10 +1295,7 @@ process_tcp_connection(struct connection *conn, const char *prog, int selflags) conn->u.tcp.offset += nread; if (conn->u.tcp.offset == 4) { unsigned char *p = (unsigned char *)conn->u.tcp.buffer; - conn->u.tcp.msglen = ((p[0] << 24) - | (p[1] << 16) - | (p[2] << 8) - | p[3]); + conn->u.tcp.msglen = load_32_be(p); if (conn->u.tcp.msglen > conn->u.tcp.bufsiz - 4) { krb5_error_code err; /* message too big */ @@ -1332,16 +1340,8 @@ process_tcp_connection(struct connection *conn, const char *prog, int selflags) goto kill_tcp_connection; } have_response: - conn->u.tcp.lenbuf[0] = 0xff & (conn->u.tcp.response->length >> 24); - conn->u.tcp.lenbuf[1] = 0xff & (conn->u.tcp.response->length >> 16); - conn->u.tcp.lenbuf[2] = 0xff & (conn->u.tcp.response->length >> 8); - conn->u.tcp.lenbuf[3] = 0xff & (conn->u.tcp.response->length >> 0); - SG_SET(&conn->u.tcp.sgbuf[1], conn->u.tcp.response->data, - conn->u.tcp.response->length); - conn->u.tcp.sgp = conn->u.tcp.sgbuf; - conn->u.tcp.sgnum = 2; + queue_tcp_outgoing_response(conn); FD_CLR(conn->fd, &sstate.rfds); - FD_SET(conn->fd, &sstate.wfds); } } else abort(); -- 2.26.2