ip: Fix unformat_ip_prefix 06/29206/3
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Thu, 1 Oct 2020 14:50:14 +0000 (16:50 +0200)
committerDave Barach <openvpp@barachs.net>
Fri, 2 Oct 2020 11:27:39 +0000 (11:27 +0000)
Type: fix

Change-Id: I73629ccf7d5a49da3858899dc727cc180fb53003
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
src/vat/ip_types.c
src/vnet/ip/ip_types.c

index 5041c12..8edcb13 100644 (file)
@@ -64,9 +64,12 @@ uword
 unformat_ip_prefix (unformat_input_t * input, va_list * args)
 {
   ip_prefix_t *a = va_arg (*args, ip_prefix_t *);
+  /* %d writes more than a u8 */
+  int plen;
   if (unformat (input, "%U/%d", unformat_ip_address, &ip_prefix_addr (a),
-               &ip_prefix_len (a)))
+               &plen))
     {
+      ip_prefix_len (a) = plen;
       if ((ip_prefix_version (a) == AF_IP4 && 32 < ip_prefix_len (a)) ||
          (ip_prefix_version (a) == AF_IP6 && 128 < ip_prefix_len (a)))
        {
index 3d489e4..6e4bb3b 100644 (file)
@@ -64,9 +64,12 @@ uword
 unformat_ip_prefix (unformat_input_t * input, va_list * args)
 {
   ip_prefix_t *a = va_arg (*args, ip_prefix_t *);
+  /* %d writes more than a u8 */
+  int plen;
   if (unformat (input, "%U/%d", unformat_ip_address, &ip_prefix_addr (a),
-               &ip_prefix_len (a)))
+               &plen))
     {
+      ip_prefix_len (a) = plen;
       if ((ip_prefix_version (a) == AF_IP4 && 32 < ip_prefix_len (a)) ||
          (ip_prefix_version (a) == AF_IP6 && 128 < ip_prefix_len (a)))
        {