aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorOle Troan <otroan@employees.org>2024-08-01 14:06:24 +0200
committerBeno�t Ganne <bganne@cisco.com>2024-08-07 11:46:51 +0000
commit9aa833b144200e88a382f3583196533c95d5e68f (patch)
tree086f8a7e38570d4bcb7e87513711eb423323f917 /src/tools
parentfa7b7a41e7ca9400dda2266a10dd9179be40c128 (diff)
vppapigen: ensure address types are nul terminated
A string generated from format() may not be nul terminated. Type: fix Change-Id: I88452e446c3504d70758e9009c65be5466034d92 Signed-off-by: Ole Troan <otroan@employees.org>
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/vppapigen/vppapigen_c.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py
index c2e1e7da7b7..2cd3c7989b3 100755
--- a/src/tools/vppapigen/vppapigen_c.py
+++ b/src/tools/vppapigen/vppapigen_c.py
@@ -171,14 +171,10 @@ class ToJSON:
write(" {\n")
# What is length field doing here?
write(
- ' u8 *s = format(0, "0x%U", format_hex_bytes, '
+ ' char *s = format_c_string(0, "0x%U", format_hex_bytes_no_wrap, '
"&a->{n}, {lfield});\n".format(n=o.fieldname, lfield=lfield)
)
- write(
- ' cJSON_AddStringToObject(o, "{n}", (char *)s);\n'.format(
- n=o.fieldname
- )
- )
+ write(' cJSON_AddStringToObject(o, "{n}", s);\n'.format(n=o.fieldname))
write(" vec_free(s);\n")
write(" }\n")
return
@@ -275,8 +271,12 @@ class ToJSON:
"(vl_api_{name}_t *a) {{\n".format(name=o.name)
)
- write(' u8 *s = format(0, "%U", format_vl_api_{}_t, a);\n'.format(o.name))
- write(" cJSON *o = cJSON_CreateString((char *)s);\n")
+ write(
+ ' char *s = format_c_string(0, "%U", format_vl_api_{}_t, a);\n'.format(
+ o.name
+ )
+ )
+ write(" cJSON *o = cJSON_CreateString(s);\n")
write(" vec_free(s);\n")
write(" return o;\n")
write("}\n")