Description
FSCompressedFileSuffixes (fs.go:456) is an exported mutable map[string]string. It is read during FSHandler initialization inside a sync.Once, but being exported, any caller can concurrently read/write this map while the Once executes.
var FSCompressedFileSuffixes = map[string]string{
"br": ".br",
"gzip": ".gz",
}
If a user modifies this map concurrently with FS initialization, it's a data race on the map (concurrent map read/write causes a fatal panic in Go).
Impact
- Fatal crash (
concurrent map read and map write) if modified after import while FS is being initialized concurrently.
- Low probability in typical usage but high severity when it occurs.
Suggested Fix
Either:
- Unexport the map and provide a
SetCompressedFileSuffixes() function that copies.
- Copy the map once at init time in the
sync.Once block, so the original can be freely modified.
Description
FSCompressedFileSuffixes(fs.go:456) is an exported mutablemap[string]string. It is read duringFSHandlerinitialization inside async.Once, but being exported, any caller can concurrently read/write this map while theOnceexecutes.If a user modifies this map concurrently with
FSinitialization, it's a data race on the map (concurrent map read/write causes a fatal panic in Go).Impact
concurrent map read and map write) if modified after import whileFSis being initialized concurrently.Suggested Fix
Either:
SetCompressedFileSuffixes()function that copies.sync.Onceblock, so the original can be freely modified.