moped
moped copied to clipboard
moped 1.5 doesn't work correctly on big-endian systems
lib/moped/bson.rb specifies the ways in which BSON fields are packed, but they currently use native endianness, which leads to errors on a big-endian system because the encoding for BSON fields are in little-endian byte order. The following patch fixes the problem.
diff --git a/lib/moped/bson.rb b/lib/moped/bson.rb
index 2136aa2..5aca1c1 100644
--- a/lib/moped/bson.rb
+++ b/lib/moped/bson.rb
@@ -16,8 +16,8 @@ module Moped
EOD = NULL_BYTE = "\u0000".freeze
- INT32_PACK = 'l'.freeze
- INT64_PACK = 'q'.freeze
+ INT32_PACK = "l<".freeze
+ INT64_PACK = 'q<'.freeze
FLOAT_PACK = 'E'.freeze
START_LENGTH = [0].pack(INT32_PACK).freeze
I can confirm this is an issue on BE systems [1] and the patch appears to fix the issues.
https://bugzilla.redhat.com/show_bug.cgi?id=1481611