Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

moped 1.5 doesn't work correctly on big-endian systems #390

Open
bryanpkc opened this issue Sep 23, 2015 · 1 comment
Open

moped 1.5 doesn't work correctly on big-endian systems #390

bryanpkc opened this issue Sep 23, 2015 · 1 comment

Comments

@bryanpkc
Copy link

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
@voxik
Copy link

voxik commented Aug 16, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants