浏览代码

x/crypto/ssh: use BigEndian.Uint32 for decoding exit status.

Change-Id: Iab40fe42454088a00abea61dfb6f368da9323eb3
Reviewed-on: https://go-review.googlesource.com/24726
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Han-Wen Nienhuys 9 年之前
父节点
当前提交
cd884d3570
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      ssh/session.go

+ 2 - 2
ssh/session.go

@@ -9,6 +9,7 @@ package ssh
 
 
 import (
 import (
 	"bytes"
 	"bytes"
+	"encoding/binary"
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
@@ -400,8 +401,7 @@ func (s *Session) wait(reqs <-chan *Request) error {
 	for msg := range reqs {
 	for msg := range reqs {
 		switch msg.Type {
 		switch msg.Type {
 		case "exit-status":
 		case "exit-status":
-			d := msg.Payload
-			wm.status = int(d[0])<<24 | int(d[1])<<16 | int(d[2])<<8 | int(d[3])
+			wm.status = int(binary.BigEndian.Uint32(msg.Payload))
 		case "exit-signal":
 		case "exit-signal":
 			var sigval struct {
 			var sigval struct {
 				Signal     string
 				Signal     string