aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-07-17 11:54:28 +0200
committerMatthew Smith <mgsmith@netgate.com>2020-07-23 22:21:25 +0000
commitc79a14f13a0db6f59123e0e6b0b71d4f24433b01 (patch)
tree1224e5f53ef51b3a9c1d69c80a60a2cb6d173adf
parent24ee40a5cb8925eadbdd612353218694c1d2f96c (diff)
feature: fix feature config data initialization overflow
Copy only exactly the data provided by the user even when it is not a 4-bytes multiple. Type: fix Change-Id: I2ef987c37e58523a38b46b09227529db2c26aa55 Signed-off-by: Benoît Ganne <bganne@cisco.com>
-rw-r--r--src/vnet/config.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/vnet/config.c b/src/vnet/config.c
index 59375746af5..4e9fa36dfc3 100644
--- a/src/vnet/config.c
+++ b/src/vnet/config.c
@@ -331,11 +331,16 @@ vnet_config_add_feature (vlib_main_t * vm,
f->feature_index = feature_index;
f->node_index = node_index;
- n_feature_config_u32s =
- round_pow2 (n_feature_config_bytes,
- sizeof (f->feature_config[0])) /
- sizeof (f->feature_config[0]);
- vec_add (f->feature_config, feature_config, n_feature_config_u32s);
+ if (n_feature_config_bytes)
+ {
+ n_feature_config_u32s =
+ round_pow2 (n_feature_config_bytes,
+ sizeof (f->feature_config[0])) /
+ sizeof (f->feature_config[0]);
+ vec_validate (f->feature_config, n_feature_config_u32s - 1);
+ clib_memcpy_fast (f->feature_config, feature_config,
+ n_feature_config_bytes);
+ }
/* Sort (prioritize) features. */
if (vec_len (new_features) > 1)