[PATCH nft 5/5] datatype: check against negative "type" argument in datatype_lookup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


An enum can be either signed or unsigned (implementation defined).

datatype_lookup() checks for invalid type arguments. Also check, whether
the argument is not negative (which, depending on the compiler it may
never be).

Signed-off-by: Thomas Haller <thaller@xxxxxxxxxx>
 src/datatype.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/datatype.c b/src/datatype.c
index ba1192c83595..91735ff8b360 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -87,7 +87,7 @@ const struct datatype *datatype_lookup(enum datatypes type)
-	if (type > TYPE_MAX)
+	if ((uintmax_t) type > TYPE_MAX)
 		return NULL;
 	return datatypes[type];

[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux