From 2a9625acf6363e16528d38cd8abd924cfde7d0c5 Mon Sep 17 00:00:00 2001 From: Jonathan Rudenberg Date: Thu, 7 Jul 2016 07:58:30 -0400 Subject: [PATCH] go test: don't rely on undefined append behavior Signed-off-by: Jason A. Donenfeld --- contrib/external-tests/go/main.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/contrib/external-tests/go/main.go b/contrib/external-tests/go/main.go index 8e3c195..c1aa293 100644 --- a/contrib/external-tests/go/main.go +++ b/contrib/external-tests/go/main.go @@ -118,15 +118,13 @@ func main() { Dst: net.IPv4(10, 189, 129, 1), }).Marshal() binary.BigEndian.PutUint16(pingHeader[2:], uint16(ipv4.HeaderLen+len(pingMessage))) // fix the length endianness on BSDs - binary.BigEndian.PutUint16(pingHeader[10:], ipChecksum(append(pingHeader, pingMessage...))) - if err != nil { - panic(err) - } + pingData := append(pingHeader, pingMessage...) + binary.BigEndian.PutUint16(pingData[10:], ipChecksum(pingData)) pingPacket := make([]byte, 13) pingPacket[0] = 4 // Type: Data binary.LittleEndian.PutUint32(pingPacket[1:], theirIndex) binary.LittleEndian.PutUint64(pingPacket[5:], 0) // Nonce - pingPacket = sendCipher.Encrypt(pingPacket, nil, append(pingHeader, pingMessage...)) + pingPacket = sendCipher.Encrypt(pingPacket, nil, pingData) if _, err := conn.Write(pingPacket); err != nil { log.Fatalf("error writing ping message: %s", err) }