[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [meek/webextension] Make the native extension work with GOARCH=386.



commit 09bde7b8c6c967f0316bae403f4f1029c588f0df
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Thu Feb 21 10:49:50 2019 -0700

    Make the native extension work with GOARCH=386.
---
 webextension/native/endian_386.go | 8 ++++++++
 webextension/native/main.go       | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/webextension/native/endian_386.go b/webextension/native/endian_386.go
new file mode 100644
index 0000000..6a1e44e
--- /dev/null
+++ b/webextension/native/endian_386.go
@@ -0,0 +1,8 @@
+// The WebExtension browserâ??app protocol uses native-endian length prefixes :/
+// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging#App_side
+
+package main
+
+import "encoding/binary"
+
+var NativeEndian = binary.LittleEndian
diff --git a/webextension/native/main.go b/webextension/native/main.go
index e98c4f1..10a2b90 100644
--- a/webextension/native/main.go
+++ b/webextension/native/main.go
@@ -139,7 +139,7 @@ func writeResponseSpec(w io.Writer, spec *responseSpec) error {
 	}
 
 	length := len(encodedSpec)
-	if length > math.MaxUint32 {
+	if uint32(length) > math.MaxUint32 {
 		return fmt.Errorf("response spec is too long to represent: %d", length)
 	}
 	err = binary.Write(w, binary.BigEndian, uint32(length))
@@ -178,7 +178,7 @@ func recvWebExtensionMessage(r io.Reader) ([]byte, error) {
 // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging#App_side
 func sendWebExtensionMessage(w io.Writer, message []byte) error {
 	length := len(message)
-	if length > math.MaxUint32 {
+	if uint32(length) > math.MaxUint32 {
 		return fmt.Errorf("WebExtension message is too long to represent: %d", length)
 	}
 	err := binary.Write(w, NativeEndian, uint32(length))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits