From 531ac242a7ebd0e08393d2a0efa7a75703eaa456 Mon Sep 17 00:00:00 2001 From: Tianyu Li Date: Thu, 8 Dec 2022 02:08:32 +0000 Subject: pppoe: fix memcpy out of bounds with gcc-11 on arm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In function ‘memcpy’, inlined from ‘clib_memcpy_fast’ at /home/vpp/src/vppinfra/string.h:86:10, inlined from ‘memcpy_s_inline’ at /home/vpp/src/vppinfra/string.h:157:7, inlined from ‘vnet_pppoe_add_del_session’ at /home/vpp/src/plugins/pppoe/pppoe.c:356:7: error: ‘__builtin_memcpy’ offset [0, 5] is out of the bounds [0, 0] [-Werror=array-bounds] 34 | return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cc1: all warnings being treated as errors Hardware address is zero length vector for PPP, use vec_len instead. Type: fix Fixes: 62f9cdd82c52 ("Add PPPoE Plugin") Signed-off-by: Tianyu Li Change-Id: If9fb409cfbbac77c15559d103987f0130bf30255 --- src/plugins/pppoe/pppoe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/pppoe/pppoe.c b/src/plugins/pppoe/pppoe.c index 2bdbd3abed8..97adc2bd082 100644 --- a/src/plugins/pppoe/pppoe.c +++ b/src/plugins/pppoe/pppoe.c @@ -353,7 +353,7 @@ int vnet_pppoe_add_del_session pool_get_aligned (pem->sessions, t, CLIB_CACHE_LINE_BYTES); clib_memset (t, 0, sizeof (*t)); - clib_memcpy (t->local_mac, hi->hw_address, 6); + clib_memcpy (t->local_mac, hi->hw_address, vec_len (hi->hw_address)); /* copy from arg structure */ #define _(x) t->x = a->x; -- cgit 1.2.3-korg