]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Use CopyExact when extracting handshake read
authorMatt Joiner <anacrolix@gmail.com>
Sun, 24 Aug 2014 19:25:52 +0000 (05:25 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 24 Aug 2014 19:25:52 +0000 (05:25 +1000)
client.go

index 0999d6dab46aa1056461a4c2435988069f364152..a513a0aee583df64d4b2c0ae77ff1ae676d8d84f 100644 (file)
--- 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[:])