Skip to content

Commit

Permalink
fix(oci): Protect read access also, not only write (#1602)
Browse files Browse the repository at this point in the history
Reviewed-by: Alexander Jung <alex@unikraft.io>
Approved-by: Alexander Jung <alex@unikraft.io>
  • Loading branch information
nderjung authored Apr 26, 2024
2 parents fc6cee1 + 453a768 commit eaa3781
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions oci/cache/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ func RemoteIndex(ref name.Reference, options ...remote.Option) (v1.ImageIndex, e
name := ref.Name()

if indexCache == nil {
indexCacheMu.Lock()
indexCache = make(map[string]v1.ImageIndex)
indexCacheMu.Unlock()
goto lookup
}

indexCacheMu.Lock()
if index, ok := indexCache[name]; ok {
indexCacheMu.Unlock()
return index, nil
}
indexCacheMu.Unlock()

lookup:
v1ImageIndex, err := remote.Index(ref, options...)
Expand Down

0 comments on commit eaa3781

Please sign in to comment.