xfrm: convert alg_key to flexible array member
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 24 May 2022 20:47:40 +0000 (13:47 -0700)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 10 Jun 2022 10:34:09 +0000 (12:34 +0200)
Iproute2 build generates a warning when built with gcc-12.
This is because the alg_key in xfrm.h API has zero size
array element instead of flexible array.

    CC       xfrm_state.o
In function ‘xfrm_algo_parse’,
    inlined from ‘xfrm_state_modify.constprop’ at xfrm_state.c:573:5:
xfrm_state.c:162:32: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  162 |                         buf[j] = val;
      |                         ~~~~~~~^~~~~

This patch convert the alg_key into flexible array member.
There are other zero size arrays here that should be converted as
well.

This patch is RFC only since it is only compile tested and
passes trivial iproute2 tests.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/uapi/linux/xfrm.h

index 65e13a099b1a0efa455bc81beabed3f98b5b1541..3ed61df9cc91541a399f6d9659f3f9293326bbb8 100644 (file)
@@ -102,21 +102,21 @@ struct xfrm_replay_state_esn {
 struct xfrm_algo {
        char            alg_name[64];
        unsigned int    alg_key_len;    /* in bits */
-       char            alg_key[0];
+       char            alg_key[];
 };
 
 struct xfrm_algo_auth {
        char            alg_name[64];
        unsigned int    alg_key_len;    /* in bits */
        unsigned int    alg_trunc_len;  /* in bits */
-       char            alg_key[0];
+       char            alg_key[];
 };
 
 struct xfrm_algo_aead {
        char            alg_name[64];
        unsigned int    alg_key_len;    /* in bits */
        unsigned int    alg_icv_len;    /* in bits */
-       char            alg_key[0];
+       char            alg_key[];
 };
 
 struct xfrm_stats {