Skip to content

Commit

Permalink
Fix out of bounds panic in registery
Browse files Browse the repository at this point in the history
When registering or updating the registry with provider information that does not have provider addresses or publisher addresses, an out of bounds panic could happen because it was assumed that the provider info whould at least have provider addresses.

This is not assumed now.
  • Loading branch information
gammazero committed Apr 4, 2022
1 parent 084dd6e commit f333592
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,12 @@ func (r *Registry) RegisterOrUpdate(ctx context.Context, providerID peer.ID, add
}

if info.Publisher.Validate() == nil && info.PublisherAddr == nil && info.Publisher == info.AddrInfo.ID {
info.PublisherAddr = info.AddrInfo.Addrs[0]
if len(info.AddrInfo.Addrs) == 0 {
log.Warnw("Register provider with no provider or publisher addresses",
"provider", info.AddrInfo.ID, "publisher", info.Publisher)
} else {
info.PublisherAddr = info.AddrInfo.Addrs[0]
}
}

if len(addrs) != 0 {
Expand Down

0 comments on commit f333592

Please sign in to comment.