summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-08-10 03:11:28 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-08-10 03:11:28 -0700
commit36093d4e5f6a77902fb9498453537ef6ef73e025 (patch)
tree68aed93679fb61fdd0922d12f484cc57345f595e /cmds
parente00dd1e5a37bed0de964b353d47a4bd7cdff532f (diff)
parentf1ab36f9ab82220de679ff0ca5164995b7d30214 (diff)
downloadframeworks_base-36093d4e5f6a77902fb9498453537ef6ef73e025.zip
frameworks_base-36093d4e5f6a77902fb9498453537ef6ef73e025.tar.gz
frameworks_base-36093d4e5f6a77902fb9498453537ef6ef73e025.tar.bz2
Merge change 20095
* changes: Fix network order for marshalling in keystore interface.
Diffstat (limited to 'cmds')
-rw-r--r--cmds/keystore/netkeystore.c1
-rw-r--r--cmds/keystore/netkeystore.h8
2 files changed, 8 insertions, 1 deletions
diff --git a/cmds/keystore/netkeystore.c b/cmds/keystore/netkeystore.c
index 637e0d8..bdd5960 100644
--- a/cmds/keystore/netkeystore.c
+++ b/cmds/keystore/netkeystore.c
@@ -242,6 +242,7 @@ static int set_read_timeout(int socket)
{
struct timeval tv;
tv.tv_sec = READ_TIMEOUT;
+ tv.tv_usec = 0;
if (setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv))
{
LOGE("setsockopt failed");
diff --git a/cmds/keystore/netkeystore.h b/cmds/keystore/netkeystore.h
index a87a667..d80ddae 100644
--- a/cmds/keystore/netkeystore.h
+++ b/cmds/keystore/netkeystore.h
@@ -19,6 +19,7 @@
#define __NETKEYSTORE_H__
#include <stdio.h>
+#include <arpa/inet.h>
#include <cutils/sockets.h>
#include <cutils/log.h>
@@ -68,6 +69,8 @@ static inline int read_marshal(int s, LPC_MARSHAL *cmd)
LOGE("failed to read header\n");
return -1;
}
+ cmd->len = ntohl(cmd->len);
+ cmd->opcode = ntohl(cmd->opcode);
if (cmd->len > BUFFER_MAX) {
LOGE("invalid size %d\n", cmd->len);
return -1;
@@ -82,11 +85,14 @@ static inline int read_marshal(int s, LPC_MARSHAL *cmd)
static inline int write_marshal(int s, LPC_MARSHAL *cmd)
{
+ int len = cmd->len;
+ cmd->len = htonl(cmd->len);
+ cmd->opcode = htonl(cmd->opcode);
if (writex(s, cmd, 2 * sizeof(uint32_t))) {
LOGE("failed to write marshal header\n");
return -1;
}
- if (writex(s, cmd->data, cmd->len)) {
+ if (writex(s, cmd->data, len)) {
LOGE("failed to write marshal data\n");
return -1;
}