diff options
author | repo sync <cywang@google.com> | 2009-08-05 18:06:27 +0800 |
---|---|---|
committer | repo sync <cywang@google.com> | 2009-08-10 16:13:00 +0800 |
commit | f1ab36f9ab82220de679ff0ca5164995b7d30214 (patch) | |
tree | bdf73fa71e3ac244eb57ba123b634d5ca78b6f52 /keystore | |
parent | 0f0767d4daa847314bd9473ef3650d26d1c51c8c (diff) | |
download | frameworks_base-f1ab36f9ab82220de679ff0ca5164995b7d30214.zip frameworks_base-f1ab36f9ab82220de679ff0ca5164995b7d30214.tar.gz frameworks_base-f1ab36f9ab82220de679ff0ca5164995b7d30214.tar.bz2 |
Fix network order for marshalling in keystore interface.
This will fix the endian issue for heterogeneous architectures in keystore marshalling interface.
Diffstat (limited to 'keystore')
-rw-r--r-- | keystore/java/android/security/ServiceCommand.java | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/keystore/java/android/security/ServiceCommand.java b/keystore/java/android/security/ServiceCommand.java index dddf654..cefae40 100644 --- a/keystore/java/android/security/ServiceCommand.java +++ b/keystore/java/android/security/ServiceCommand.java @@ -121,15 +121,16 @@ public class ServiceCommand { Reply reply = new Reply(); if (!readBytes(buf, 4)) return null; - reply.len = (((int) buf[0]) & 0xff) | ((((int) buf[1]) & 0xff) << 8) | - ((((int) buf[2]) & 0xff) << 16) | - ((((int) buf[3]) & 0xff) << 24); + reply.len = ((((int) buf[0]) & 0xff) << 24) | + ((((int) buf[1]) & 0xff) << 16) | + ((((int) buf[2]) & 0xff) << 8) | + (((int) buf[3]) & 0xff); if (!readBytes(buf, 4)) return null; - reply.returnCode = (((int) buf[0]) & 0xff) | - ((((int) buf[1]) & 0xff) << 8) | - ((((int) buf[2]) & 0xff) << 16) | - ((((int) buf[3]) & 0xff) << 24); + reply.returnCode = ((((int) buf[0]) & 0xff) << 24) | + ((((int) buf[1]) & 0xff) << 16) | + ((((int) buf[2]) & 0xff) << 8) | + (((int) buf[3]) & 0xff); if (reply.len > BUFFER_LENGTH) { Log.e(mTag,"invalid reply length (" + reply.len + ")"); @@ -145,15 +146,15 @@ public class ServiceCommand { byte[] data = (_data == null) ? new byte[0] : _data.getBytes(); int len = data.length; // the length of data - buf[0] = (byte) (len & 0xff); - buf[1] = (byte) ((len >> 8) & 0xff); - buf[2] = (byte) ((len >> 16) & 0xff); - buf[3] = (byte) ((len >> 24) & 0xff); + buf[0] = (byte) ((len >> 24) & 0xff); + buf[1] = (byte) ((len >> 16) & 0xff); + buf[2] = (byte) ((len >> 8) & 0xff); + buf[3] = (byte) (len & 0xff); // the opcode of the command - buf[4] = (byte) (cmd & 0xff); - buf[5] = (byte) ((cmd >> 8) & 0xff); - buf[6] = (byte) ((cmd >> 16) & 0xff); - buf[7] = (byte) ((cmd >> 24) & 0xff); + buf[4] = (byte) ((cmd >> 24) & 0xff); + buf[5] = (byte) ((cmd >> 16) & 0xff); + buf[6] = (byte) ((cmd >> 8) & 0xff); + buf[7] = (byte) (cmd & 0xff); try { mOut.write(buf, 0, 8); mOut.write(data, 0, len); |