Skip to content
Permalink
Browse files Browse the repository at this point in the history
fix oob read on luac
  • Loading branch information
wargio committed Aug 21, 2022
1 parent 06ee5e3 commit 07b43bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion librz/bin/bobj.c
Expand Up @@ -244,7 +244,7 @@ static RzList *classes_from_symbols(RzBinFile *bf) {
RzBinSymbol *sym;
RzListIter *iter;
rz_list_foreach (bf->o->symbols, iter, sym) {
if (sym->name[0] != '_') {
if (!sym->name || sym->name[0] != '_') {
continue;
}
const char *cn = sym->classname;
Expand Down
5 changes: 4 additions & 1 deletion librz/bin/format/luac/luac_bin.c
Expand Up @@ -303,7 +303,7 @@ void _luac_build_info(LuaProto *proto, LuacBinInfo *info) {
}

// 2.2 parse debug_upvalues
size_t real_upvalue_cnt = rz_list_length(proto->upvalue_entries);
size_t real_upvalue_cnt = RZ_MAX(rz_list_length(proto->upvalue_entries), rz_list_length(proto->dbg_upvalue_entries));
if (real_upvalue_cnt > 0) {
LuaDbgUpvalueEntry *debug_upv_entry;
upvalue_names = RZ_NEWS0(char *, real_upvalue_cnt);
Expand All @@ -328,6 +328,9 @@ void _luac_build_info(LuaProto *proto, LuacBinInfo *info) {
LuaConstEntry *const_entry;
rz_list_foreach (proto->const_entries, iter, const_entry) {
symbol_name = get_constant_symbol_name(proto_name, const_entry);
if (!symbol_name) {
continue;
}
luac_add_symbol(
info->symbol_list,
symbol_name,
Expand Down

0 comments on commit 07b43bc

Please sign in to comment.