mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Limit stringified bytes to address length
...to match the behaviour of Address.String before the change to make Address an opaque type. PiperOrigin-RevId: 536481989
This commit is contained in:
committed by
gVisor bot
parent
08ff84c6e7
commit
c5da2f6543
+2
-2
@@ -2508,7 +2508,7 @@ func clone(dst reflect.Value, src reflect.Value) {
|
||||
|
||||
// String implements the fmt.Stringer interface.
|
||||
func (a Address) String() string {
|
||||
switch a.Len() {
|
||||
switch l := a.Len(); l {
|
||||
case 4:
|
||||
return fmt.Sprintf("%d.%d.%d.%d", int(a.addr[0]), int(a.addr[1]), int(a.addr[2]), int(a.addr[3]))
|
||||
case 16:
|
||||
@@ -2549,7 +2549,7 @@ func (a Address) String() string {
|
||||
}
|
||||
return b.String()
|
||||
default:
|
||||
return fmt.Sprintf("%x", a.addr[:])
|
||||
return fmt.Sprintf("%x", a.addr[:l])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user