iproute2: fix hidden uint to uin64_t promotion in json_print
authorKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Sun, 18 Mar 2018 15:50:04 +0000 (15:50 +0000)
committerHans Dedecker <dedeckeh@gmail.com>
Mon, 19 Mar 2018 10:40:01 +0000 (11:40 +0100)
print_int used 'int' type internally, whereas print_uint used 'uint64_t'

These helper functions eventually call vfprintf(fp, fmt, args) which is
a variable argument list function and is dependent upon 'fmt' containing
correct information about the length of the passed arguments.

Unfortunately print_int v print_uint offered no clue to the programmer
that internally passed ints to print_uint were being promoted to 64bits,
thus the format passed in 'fmt' string vs the actual passed integer
could be different lengths.  This is even more interesting on big endian
architectures where 'vfprintf' would be looking in the middle of an
int64 type.  Symptoms of this included tc qdisc showing bizarre values
for a variety of fields across a variety of qdiscs (e.g. refcnt, flows,
quantum)

print_u/int now stick with native int size.

A similar patch has been sent upstream.

Fixes FS#1425

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
package/network/utils/iproute2/Makefile
package/network/utils/iproute2/patches/910-iproute2-fix-hidden-uint-to-uin64_t-promottion-in-js.patch [new file with mode: 0644]

index eaee4838ed9f1cdf72c2d3fafe3a39c6c42d63f2..d8ff5e590d42ea3a6632aaa88eccfa13efccd0f2 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=iproute2
 PKG_VERSION:=4.15.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
diff --git a/package/network/utils/iproute2/patches/910-iproute2-fix-hidden-uint-to-uin64_t-promottion-in-js.patch b/package/network/utils/iproute2/patches/910-iproute2-fix-hidden-uint-to-uin64_t-promottion-in-js.patch
new file mode 100644 (file)
index 0000000..a549770
--- /dev/null
@@ -0,0 +1,65 @@
+From e1c6b35f9f978f6919e8bf651de67b30dc145543 Mon Sep 17 00:00:00 2001
+From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+Date: Sun, 18 Mar 2018 08:51:08 +0000
+Subject: [PATCH] iproute2: fix hidden uint to uin64_t promotion in json_print
+
+print_int used 'int' type internally, whereas print_uint used 'uint64_t'
+
+These helper functions eventually call vfprintf(fp, fmt, args) which is
+a variable argument list function and is dependent upon 'fmt' containing
+correct information about the length of the passed arguments.
+
+Unfortunately print_int v print_uint offered no clue to the programmer
+that internally passed ints to print_uint were being promoted to 64bits,
+thus the format passed in 'fmt' string vs the actual passed integer
+could be different lengths.  This is even more interesting on big endian
+architectures where 'vfprintf' would be looking in the middle of an
+int64 type.  Symptoms of this included tc qdisc showing bizarre values
+for a variety of fields across a variety of qdiscs (e.g. refcnt, flows,
+quantum)
+
+print_u/int now stick with native int size.
+
+A similar patch has been sent upstream.
+
+Fixes FS#1425
+
+Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+---
+ include/json_print.h | 2 +-
+ lib/json_print.c     | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/include/json_print.h b/include/json_print.h
+index dc4d2bb3..350d35cb 100644
+--- a/include/json_print.h
++++ b/include/json_print.h
+@@ -56,10 +56,10 @@ void close_json_array(enum output_type type, const char *delim);
+               print_color_##type_name(t, COLOR_NONE, key, fmt, value);        \
+       }
+ _PRINT_FUNC(int, int);
++_PRINT_FUNC(uint, unsigned int);
+ _PRINT_FUNC(bool, bool);
+ _PRINT_FUNC(null, const char*);
+ _PRINT_FUNC(string, const char*);
+-_PRINT_FUNC(uint, uint64_t);
+ _PRINT_FUNC(hu, unsigned short);
+ _PRINT_FUNC(hex, unsigned int);
+ _PRINT_FUNC(0xhex, unsigned int);
+diff --git a/lib/json_print.c b/lib/json_print.c
+index aa527af6..ae3a317d 100644
+--- a/lib/json_print.c
++++ b/lib/json_print.c
+@@ -117,8 +117,8 @@ void close_json_array(enum output_type type, const char *str)
+               }                                                       \
+       }
+ _PRINT_FUNC(int, int);
++_PRINT_FUNC(uint, unsigned int);
+ _PRINT_FUNC(hu, unsigned short);
+-_PRINT_FUNC(uint, uint64_t);
+ _PRINT_FUNC(lluint, unsigned long long int);
+ #undef _PRINT_FUNC
+-- 
+2.14.3 (Apple Git-98)
+