With --enable-Werror and --with-dpdk=no: In function 'ovs_strlcpy', inlined from 'ovs_strlcpy' at ../lib/util.c:377:1, inlined from 'ofputil_port_to_string' at ../lib/ofp-port.c:273:9, inlined from 'ofputil_port_from_string.part.0' at ../lib/ofp-port.c:170:13: ../lib/util.c:380:22: error: 'strnlen' specified bound 15 may exceed source size 11 [-Werror=stringop-overread] 380 | size_t len = strnlen(src, size - 1); | ^
Fixes: 28b114322856 ("ofp-util: New function ofputil_port_to_string().") Signed-off-by: Eli Britstein <el...@nvidia.com> --- lib/ofp-port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ofp-port.c b/lib/ofp-port.c index 16d587488..6e884cd3f 100644 --- a/lib/ofp-port.c +++ b/lib/ofp-port.c @@ -270,7 +270,8 @@ ofputil_port_to_string(ofp_port_t port, { const char *reserved_name = ofputil_port_get_reserved_name(port); if (reserved_name) { - ovs_strlcpy(namebuf, reserved_name, bufsize); + ovs_strlcpy(namebuf, reserved_name, MIN(strlen(reserved_name), + bufsize)); return; } -- 2.26.2.1730.g385c171 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev