diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2015-12-11 08:40:59 +0100 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2015-12-11 09:42:50 +0000 |
commit | f142595db72955260976d4257592032bef7d492a (patch) | |
tree | 13707cb6f47cffbe563a5f1a55cf2ead49832806 | |
parent | 2fd168c134092a4e0cc587f6c474dd38681a6c23 (diff) |
Lua: Validate ProtoExpert.new arguments
Change-Id: I0da829041cda48a35341c315a7889b557b6334d7
Reviewed-on: https://code.wireshark.org/review/12527
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
-rw-r--r-- | epan/wslua/wslua_proto_expert.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/epan/wslua/wslua_proto_expert.c b/epan/wslua/wslua_proto_expert.c index e2d0452bce..4c11754b3c 100644 --- a/epan/wslua/wslua_proto_expert.c +++ b/epan/wslua/wslua_proto_expert.c @@ -54,7 +54,8 @@ WSLUA_CONSTRUCTOR ProtoExpert_new(lua_State* L) { `expert.group.REQUEST_CODE`, `expert.group.UNDECODED`, `expert.group.REASSEMBLE`, `expert.group.MALFORMED`, `expert.group.DEBUG`, `expert.group.PROTOCOL`, - `expert.group.SECURITY`, or `expert.group.COMMENTS_GROUP`. */ + `expert.group.SECURITY`, `expert.group.COMMENTS_GROUP` + or `expert.group.DECRYPTION`. */ #define WSLUA_ARG_ProtoExpert_new_SEVERITY 4 /* Expert severity type: one of: `expert.severity.COMMENT`, `expert.severity.CHAT`, `expert.severity.NOTE`, `expert.severity.WARN`, @@ -66,6 +67,52 @@ WSLUA_CONSTRUCTOR ProtoExpert_new(lua_State* L) { int group = (int)luaL_checkinteger(L, WSLUA_ARG_ProtoExpert_new_GROUP); int severity = (int)luaL_checkinteger(L, WSLUA_ARG_ProtoExpert_new_SEVERITY); + if (!abbr[0]) { + luaL_argerror(L, WSLUA_ARG_ProtoExpert_new_ABBR, "Empty field name abbrev"); + return 0; + } + + if (proto_check_field_name(abbr)) { + luaL_argerror(L, WSLUA_ARG_ProtoExpert_new_ABBR, "Invalid char in abbrev"); + return 0; + } + + if (proto_registrar_get_byname(abbr)) { + luaL_argerror(L, WSLUA_ARG_ProtoExpert_new_ABBR, "This abbrev already exists"); + return 0; + } + + switch (group) { + case PI_CHECKSUM: + case PI_SEQUENCE: + case PI_RESPONSE_CODE: + case PI_REQUEST_CODE: + case PI_UNDECODED: + case PI_REASSEMBLE: + case PI_MALFORMED: + case PI_DEBUG: + case PI_PROTOCOL: + case PI_SECURITY: + case PI_COMMENTS_GROUP: + case PI_DECRYPTION: + break; + default: + luaL_argerror(L, WSLUA_ARG_ProtoExpert_new_GROUP, "Group must be one of expert.group.*"); + return 0; + } + + switch (severity) { + case PI_COMMENT: + case PI_CHAT: + case PI_NOTE: + case PI_WARN: + case PI_ERROR: + break; + default: + luaL_argerror(L, WSLUA_ARG_ProtoExpert_new_SEVERITY, "Severity must be one of expert.severity.*"); + return 0; + } + pe = g_new(wslua_expert_field_t,1); pe->ids.ei = EI_INIT_EI; |