OSDN Git Service

sctp: delete the nested flexible array hmac
authorXin Long <lucien.xin@gmail.com>
Wed, 19 Apr 2023 15:16:32 +0000 (11:16 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Apr 2023 07:19:30 +0000 (08:19 +0100)
This patch deletes the flexible-array hmac[] from the structure
sctp_authhdr to avoid some sparse warnings:

  # make C=2 CF="-Wflexible-array-nested" M=./net/sctp/
  net/sctp/auth.c: note: in included file (through include/net/sctp/structs.h, include/net/sctp/sctp.h):
  ./include/linux/sctp.h:735:29: warning: nested flexible array

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/sctp.h
net/sctp/auth.c
net/sctp/sm_statefuns.c

index 01a0eb7..d182e8c 100644 (file)
@@ -727,7 +727,7 @@ struct sctp_addip_chunk {
 struct sctp_authhdr {
        __be16 shkey_id;
        __be16 hmac_id;
-       __u8   hmac[];
+       /* __u8   hmac[]; */
 };
 
 struct sctp_auth_chunk {
index 3496414..c58fffc 100644 (file)
@@ -738,7 +738,7 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc,
 
        tfm = asoc->ep->auth_hmacs[hmac_id];
 
-       digest = auth->auth_hdr.hmac;
+       digest = (u8 *)(&auth->auth_hdr + 1);
        if (crypto_shash_setkey(tfm, &asoc_key->data[0], asoc_key->len))
                goto free;
 
index 7b8eb73..97f1155 100644 (file)
@@ -4391,7 +4391,7 @@ static enum sctp_ierror sctp_sf_authenticate(
         *  3. Compute the new digest
         *  4. Compare saved and new digests.
         */
-       digest = auth_hdr->hmac;
+       digest = (u8 *)(auth_hdr + 1);
        skb_pull(chunk->skb, sig_len);
 
        save_digest = kmemdup(digest, sig_len, GFP_ATOMIC);