]> Cypherpunks repositories - gostls13.git/commitdiff
exp/ssh: fix three shift bugs related to packet lengths
authorDave Cheney <dave@cheney.net>
Mon, 28 Nov 2011 17:10:16 +0000 (12:10 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 28 Nov 2011 17:10:16 +0000 (12:10 -0500)
Thanks for Ke Lan for the initial report and investigation.

R=agl, gustav.paul, tg8866, rsc
CC=golang-dev
https://golang.org/cl/5443044

src/pkg/exp/ssh/channel.go
src/pkg/exp/ssh/client.go

index 6ff8203ce27d6cb29f37c9317f60cd111407ca19..9d75f37de748fe35fef2f9f0bf38bb80a0ffef6c 100644 (file)
@@ -244,13 +244,13 @@ func (c *channel) Write(data []byte) (n int, err error) {
 
                packet := make([]byte, 1+4+4+len(todo))
                packet[0] = msgChannelData
-               packet[1] = byte(c.theirId) >> 24
-               packet[2] = byte(c.theirId) >> 16
-               packet[3] = byte(c.theirId) >> 8
+               packet[1] = byte(c.theirId >> 24)
+               packet[2] = byte(c.theirId >> 16)
+               packet[3] = byte(c.theirId >> 8)
                packet[4] = byte(c.theirId)
-               packet[5] = byte(len(todo)) >> 24
-               packet[6] = byte(len(todo)) >> 16
-               packet[7] = byte(len(todo)) >> 8
+               packet[5] = byte(len(todo) >> 24)
+               packet[6] = byte(len(todo) >> 16)
+               packet[7] = byte(len(todo) >> 8)
                packet[8] = byte(len(todo))
                copy(packet[9:], todo)
 
index 39aee80420748b933552201d16df1b88c46ad930..f22782244c9edf271910d51b76e071057735e1bc 100644 (file)
@@ -403,8 +403,8 @@ func (w *chanWriter) Write(data []byte) (n int, err error) {
                n = len(data)
                packet := make([]byte, 0, 9+n)
                packet = append(packet, msgChannelData,
-                       byte(w.peersId)>>24, byte(w.peersId)>>16, byte(w.peersId)>>8, byte(w.peersId),
-                       byte(n)>>24, byte(n)>>16, byte(n)>>8, byte(n))
+                       byte(w.peersId>>24), byte(w.peersId>>16), byte(w.peersId>>8), byte(w.peersId),
+                       byte(n>>24), byte(n>>16), byte(n>>8), byte(n))
                err = w.writePacket(append(packet, data...))
                w.rwin -= n
                return