소스 검색

Merge pull request #190 from go-sql-driver/cipher_memsafe

ensure cipher memory safety
Julien Schmidt 12 년 전
부모
커밋
b1aa46e2d6
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      packets.go

+ 5 - 1
packets.go

@@ -188,9 +188,13 @@ func (mc *mysqlConn) readInitPacket() ([]byte, error) {
 		//	return
 		//}
 		//return errMalformPkt
+		return cipher, nil
 	}
 
-	return cipher, nil
+	// make a memory safe copy of the cipher slice
+	var b [8]byte
+	copy(b[:], cipher)
+	return b[:], nil
 }
 
 // Client Authentication Packet