Skip to content

Commit

Permalink
fix: check KernelSymbolTable initialized before getting symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
AsafEitani authored and rafaeldtinoco committed Aug 1, 2022
1 parent 40a7f68 commit 60eea00
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helpers/kernel_symbols.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func (k *KernelSymbolTable) TextSegmentContains(addr uint64) (bool, error) {

// GetSymbolByName returns a symbol by a given name and owner
func (k *KernelSymbolTable) GetSymbolByName(owner string, name string) (*KernelSymbol, error) {
if !k.initialized {
return nil, errors.New("kernel symbols map isnt initialized")
}
key := fmt.Sprintf("%s_%s", owner, name)
symbol, exist := k.symbolMap[key]
if exist {
Expand All @@ -103,6 +106,9 @@ func (k *KernelSymbolTable) GetSymbolByName(owner string, name string) (*KernelS

// GetSymbolByAddr returns a symbol by a given address
func (k *KernelSymbolTable) GetSymbolByAddr(addr uint64) (*KernelSymbol, error) {
if !k.initialized {
return nil, errors.New("kernel symbols map isnt initialized")
}
for _, Symbol := range k.symbolMap {
if Symbol.Address == addr {
return &Symbol, nil
Expand Down

0 comments on commit 60eea00

Please sign in to comment.