aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-12-11 17:54:03 +0100
committerStig Bjørlykke <stig@bjorlykke.org>2015-12-11 16:56:43 +0000
commitb031e538f707cead2aa3e9d956eb88ff1d0db4fc (patch)
tree66b91e07f635d6b91dec0654adee9bd28ce24c1a /epan
parent6586926a477a4c504ee1b7672757f728cef7b0b3 (diff)
Lua: Check for empty name in ProtoField
The check in tmp_fld_check_assert() does terminate with g_error if given an empty string as name, so we have to check for this. Change-Id: I084e3e715bd319484a52f60ef90c1a2aea30df1b Reviewed-on: https://code.wireshark.org/review/12534 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'epan')
-rw-r--r--epan/wslua/wslua_proto_field.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/epan/wslua/wslua_proto_field.c b/epan/wslua/wslua_proto_field.c
index 50dd10dff5..61861e93c1 100644
--- a/epan/wslua/wslua_proto_field.c
+++ b/epan/wslua/wslua_proto_field.c
@@ -336,6 +336,11 @@ WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L) {
guint32 mask = wslua_optguint32(L, WSLUA_OPTARG_ProtoField_new_MASK, 0x0);
const gchar *blob = luaL_optstring(L,WSLUA_OPTARG_ProtoField_new_DESCR,NULL);
+ if (!name[0]) {
+ WSLUA_ARG_ERROR(ProtoField_new,NAME,"cannot be an empty string");
+ return 0;
+ }
+
if (lua_isnumber(L,WSLUA_ARG_ProtoField_new_TYPE)) {
type = (enum ftenum)luaL_checkinteger(L,WSLUA_ARG_ProtoField_new_TYPE);
} else {
@@ -515,6 +520,11 @@ static int ProtoField_integer(lua_State* L, enum ftenum type) {
guint32 mask = wslua_optguint32(L,5,0);
const gchar* blob = luaL_optstring(L,6,NULL);
+ if (!name[0]) {
+ luaL_argerror(L, 2, "cannot be an empty string");
+ return 0;
+ }
+
if (lua_gettop(L) > 3 && !lua_isnil(L, 4)) {
if (type == FT_FRAMENUM) {
framenum_type = (enum ft_framenum_type) luaL_checkinteger(L, 4);
@@ -696,6 +706,11 @@ static int ProtoField_boolean(lua_State* L, enum ftenum type) {
guint32 mask = wslua_optguint32(L,5,0);
const gchar* blob = luaL_optstring(L,6,NULL);
+ if (!name[0]) {
+ luaL_argerror(L, 2, "cannot be an empty string");
+ return 0;
+ }
+
if (mask == 0x0 && base != BASE_NONE) {
luaL_argerror(L,3,"Fieldbase (fielddisplay) must be base.NONE"
" if bitmask is zero.");
@@ -753,6 +768,11 @@ static int ProtoField_time(lua_State* L,enum ftenum type) {
unsigned base = (unsigned)luaL_optinteger(L,3,ABSOLUTE_TIME_LOCAL);
const gchar* blob = NULL;
+ if (!name[0]) {
+ luaL_argerror(L, 2, "cannot be an empty string");
+ return 0;
+ }
+
if (type == FT_ABSOLUTE_TIME) {
abbr = check_field_name(L,1,type);
blob = luaL_optstring(L,4,NULL);
@@ -809,6 +829,11 @@ static int ProtoField_other(lua_State* L,enum ftenum type) {
const gchar* name = luaL_optstring(L,2,abbr);
const gchar* blob = luaL_optstring(L,3,NULL);
+ if (!name[0]) {
+ luaL_argerror(L, 2, "cannot be an empty string");
+ return 0;
+ }
+
f = g_new(wslua_field_t,1);
f->hfid = -2;