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>
This commit is contained in:
parent
dd2a2d432a
commit
d32c3dab46
|
@ -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. */
|
||||
|
|
Loading…
Reference in New Issue