From 1ac83af5605a941f3c7bf2d7f3449f2c1e8e2af9 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 25 Feb 2020 10:06:49 +0100 Subject: [PATCH] CLEANUP: connection: use read_u32() instead of a cast in the netscaler parser The netscaler protocol parser used to involve a few casts from char to (uint32_t*), let's properly use u32 for this instead. --- src/connection.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/connection.c b/src/connection.c index 06f2b7b..4ebbd42 100644 --- a/src/connection.c +++ b/src/connection.c @@ -837,17 +837,17 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag) /* Decode a possible NetScaler Client IP request, fail early if * it does not match */ - if (ntohl(*(uint32_t *)line) != __objt_listener(conn->target)->bind_conf->ns_cip_magic) + if (ntohl(read_u32(line)) != __objt_listener(conn->target)->bind_conf->ns_cip_magic) goto bad_magic; /* Legacy CIP protocol */ if ((trash.area[8] & 0xD0) == 0x40) { - hdr_len = ntohl(*(uint32_t *)(line+4)); + hdr_len = ntohl(read_u32((line+4))); line += 8; } /* Standard CIP protocol */ else if (trash.area[8] == 0x00) { - hdr_len = ntohs(*(uint32_t *)(line+10)); + hdr_len = ntohs(read_u32((line+10))); line += 12; } /* Unknown CIP protocol */ -- 1.7.10.4