Use crypto/rand.Read, not crypto.Reader.Read
The current code accidentally ignores partial reads, since it doesn't check the return value of (io.Reader).Read. What we actually want is io.ReadFull(rand.Reader, buf), which is conveniently provided by rand.Read(buf). Signed-off-by: edef <edef@edef.eu>
This commit is contained in:
@ -53,7 +53,7 @@ func NewNS() (ns.NetNS, error) {
|
||||
nsRunDir := getNsRunDir()
|
||||
|
||||
b := make([]byte, 16)
|
||||
_, err := rand.Reader.Read(b)
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to generate random netns name: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user