Skip to contentSkip to conversation

Warnings build iproute2 with gcc-12 in xfrm

DISCUSSION Stephen Hemminger 1 participant 1 message May 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Iproute2 now gets warning in xfrm code with Gcc-12

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;
      |                         ~~~~~~~^~~~~

Fixing it properly would be hard since buf points to element in alg union which can be from xfrm.h. I.e:

struct xfrm_algo {
	char		alg_name[64];
	unsigned int	alg_key_len;    /* in bits */
	char		alg_key[0];
};

Looks like use of legacy zero sized arrays in uapi is the underlying root cause.

Any good suggestions on best fix here?