]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: connection: use read_u32() instead of a cast in the netscaler parser
authorWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 09:06:49 +0000 (10:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 09:24:51 +0000 (10:24 +0100)
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

index 06f2b7bc2fce79006fe551357745cf0375cb38a8..4ebbd42b922fcd099d2c46d342b630c1c15de3d6 100644 (file)
@@ -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 */