From: Matt Joiner Date: Sun, 24 Aug 2014 19:25:52 +0000 (+1000) Subject: Use CopyExact when extracting handshake read X-Git-Tag: v1.0.0~1603 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=8f89d7a07ed82ed441125e7f989551d099eba5f4;p=btrtrc.git Use CopyExact when extracting handshake read --- diff --git a/client.go b/client.go index 0999d6da..a513a0ae 100644 --- a/client.go +++ b/client.go @@ -448,9 +448,9 @@ func handshake(sock io.ReadWriteCloser, ih *InfoHash, peerID [20]byte) (res hand if string(b[:20]) != pp.Protocol { return } - copy(res.peerExtensionBytes[:], b[20:28]) - copy(res.InfoHash[:], b[28:48]) - copy(res.peerID[:], b[48:68]) + CopyExact(&res.peerExtensionBytes, b[20:28]) + CopyExact(&res.InfoHash, b[28:48]) + CopyExact(&res.peerID, b[48:68]) if ih == nil { // We were waiting for the peer to tell us what they wanted. post(res.InfoHash[:])