fib: fix off-by-one error in rewrite length check
The rewrite string can be up to max_size, and max_size can be up to
VNET_REWRITE_TOTAL_BYTES. Don't waste the last byte.
Type: fix
Change-Id: I2fb7e9873b6b4c1e6a55b172c7f753f3c5910802
Signed-off-by: Benoît Ganne <bganne@cisco.com>
diff --git a/src/vnet/adj/rewrite.h b/src/vnet/adj/rewrite.h
index 5cb90e4..06b1b00 100644
--- a/src/vnet/adj/rewrite.h
+++ b/src/vnet/adj/rewrite.h
@@ -147,8 +147,8 @@
int max_size, void *data, int data_bytes)
{
/* Sanity check values carefully for this clib_memset operation */
- ASSERT ((max_size > 0) && (max_size < VNET_REWRITE_TOTAL_BYTES));
- ASSERT ((data_bytes >= 0) && (data_bytes < max_size));
+ ASSERT ((max_size > 0) && (max_size <= VNET_REWRITE_TOTAL_BYTES));
+ ASSERT ((data_bytes >= 0) && (data_bytes <= max_size));
rw->data_bytes = data_bytes;
clib_memcpy_fast (rw->data, data, data_bytes);