diff mbox series

[ovs-dev,1/3] ofp-group: Use big-enough buffer in ofputil_format_group().

Message ID 20210506175410.344793-2-blp@ovn.org
State Accepted
Headers show
Series GCC 11 warning fixes | expand

Commit Message

Ben Pfaff May 6, 2021, 5:54 p.m. UTC
GCC 11 pointed out that ofputil_group_to_string()'s prototype asks for
a buffer with one byte more than supplied.  This fixes the problem.

This wasn't a buffer overflow because ofputil_group_to_string() honors
the buffer size passed in, which was correct.  The worst that could
happen was truncating the last byte of a group name.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 lib/ofp-group.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/ofp-group.c b/lib/ofp-group.c
index bf0f8af544c9..737f48047b10 100644
--- a/lib/ofp-group.c
+++ b/lib/ofp-group.c
@@ -64,7 +64,7 @@  ofputil_group_from_string(const char *s, uint32_t *group_idp)
 void
 ofputil_format_group(uint32_t group_id, struct ds *s)
 {
-    char name[MAX_GROUP_NAME_LEN];
+    char name[MAX_GROUP_NAME_LEN + 1];
 
     ofputil_group_to_string(group_id, name, sizeof name);
     ds_put_cstr(s, name);