aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_proto_field.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2017-03-14 10:33:29 +0100
committerPeter Wu <peter@lekensteyn.nl>2017-03-14 15:12:36 +0000
commitc899dd57ffb81075e6f20f4af83daf99ef4e8b0c (patch)
tree8e62bea4fe3acb772eed49242de549c44913889c /epan/wslua/wslua_proto_field.c
parentd89bb12d1feb41fb7b2cb6ed93266054f9ee4377 (diff)
Lua: Improve base checking for signed integer
Check base value for signed integer before unsigned to avoid a case where the valid bases for a unsigned integer is presented in a error message when a signed type is used. Change-Id: Idfb87597779652e32adceacad220d748afda5e85 Reviewed-on: https://code.wireshark.org/review/20541 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/wslua/wslua_proto_field.c')
-rw-r--r--epan/wslua/wslua_proto_field.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/epan/wslua/wslua_proto_field.c b/epan/wslua/wslua_proto_field.c
index 4263bc9de6..64c3b667b1 100644
--- a/epan/wslua/wslua_proto_field.c
+++ b/epan/wslua/wslua_proto_field.c
@@ -495,15 +495,15 @@ WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L) {
base = BASE_OCT; /* default base for characters (BASE_HEX instead?) */
else
base = BASE_DEC; /* Default base for integer */
- } else if (base < BASE_DEC || base > BASE_HEX_DEC) {
- WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Base must be either base.DEC, base.HEX, base.OCT,"
- " base.DEC_HEX, base.HEX_DEC or base.UNIT_STRING");
- return 0;
}
if ((base != BASE_DEC) &&
(type == FT_INT8 || type == FT_INT16 || type == FT_INT24 || type == FT_INT32 || type == FT_INT64))
{
- WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Base must be base.DEC or base.UNIT_STRING for signed integer");
+ WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Base must be either base.DEC or base.UNIT_STRING");
+ return 0;
+ } else if (base < BASE_DEC || base > BASE_HEX_DEC) {
+ WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Base must be either base.DEC, base.HEX, base.OCT,"
+ " base.DEC_HEX, base.HEX_DEC or base.UNIT_STRING");
return 0;
}
if (nargs >= WSLUA_OPTARG_ProtoField_new_VALUESTRING &&
@@ -698,14 +698,14 @@ static int ProtoField_integer(lua_State* L, enum ftenum type) {
luaL_argerror(L, 3, "FRAMENUM must use base.NONE");
else if (mask)
luaL_argerror(L, 5, "FRAMENUM can not have a bitmask");
+ } else if ((base != BASE_DEC) &&
+ (type == FT_INT8 || type == FT_INT16 || type == FT_INT24 || type == FT_INT32 || type == FT_INT64)) {
+ luaL_argerror(L, 3, "Base must be either base.DEC or base.UNIT_STRING");
+ return 0;
} else if (base < BASE_DEC || base > BASE_HEX_DEC) {
luaL_argerror(L, 3, "Base must be either base.DEC, base.HEX, base.OCT,"
" base.DEC_HEX, base.HEX_DEC or base.UNIT_STRING");
return 0;
- } else if ((base != BASE_DEC) &&
- (type == FT_INT8 || type == FT_INT16 || type == FT_INT24 || type == FT_INT32 || type == FT_INT64)) {
- luaL_argerror(L, 3, "Base must be base.DEC or base.UNIT_STRING for signed integer");
- return 0;
}
f = g_new(wslua_field_t,1);