diff options
author | Hadriel Kaplan <hadrielk@yahoo.com> | 2015-08-21 11:59:34 -0400 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2015-08-21 17:42:32 +0000 |
commit | d32c3dab46266aa94eb81c6a41f2dfb9cbf35a0e (patch) | |
tree | 2d8a51430f20e3cca08a19ffa6075c78b70c35dc /epan/wslua | |
parent | dd2a2d432a0c1e7ca5b0fe56da8624619f23e35d (diff) |
Lua: check sscanf return value
Wslua's Int64.fromhex() and UInt64.fromhex() need to check the sscanf return
value. Found by coverity (CID 1191368 &1191369).
Change-Id: I67fba027e18341d429787515f94c794573dc41c2
Reviewed-on: https://code.wireshark.org/review/10183
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/wslua')
-rw-r--r-- | epan/wslua/wslua_int64.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/epan/wslua/wslua_int64.c b/epan/wslua/wslua_int64.c index c2e641d7b0..7ba73b498e 100644 --- a/epan/wslua/wslua_int64.c +++ b/epan/wslua/wslua_int64.c @@ -256,7 +256,9 @@ WSLUA_CONSTRUCTOR Int64_fromhex(lua_State* L) { const gchar *s = luaL_checklstring(L,WSLUA_ARG_Int64_fromhex_HEX,&len); if (len > 0) { - sscanf(s, "%" G_GINT64_MODIFIER "x", &result); + if (sscanf(s, "%" G_GINT64_MODIFIER "x", &result) != 1) { + return luaL_error(L, "Error decoding the passed-in hex string"); + } } pushInt64(L,(gint64)result); WSLUA_RETURN(1); /* The new `Int64` object. */ @@ -816,7 +818,9 @@ WSLUA_CONSTRUCTOR UInt64_fromhex(lua_State* L) { const gchar *s = luaL_checklstring(L,WSLUA_ARG_UInt64_fromhex_HEX,&len); if (len > 0) { - sscanf(s, "%" G_GINT64_MODIFIER "x", &result); + if (sscanf(s, "%" G_GINT64_MODIFIER "x", &result) != 1) { + return luaL_error(L, "Error decoding the passed-in hex string"); + } } pushUInt64(L,result); WSLUA_RETURN(1); /* The new `UInt64` object. */ |