summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2010-03-08 17:21:35 +0800
committerChia-chi Yeh <chiachi@android.com>2010-03-08 17:21:35 +0800
commit61b09cbc027bdfe478ac79c59494953b6cea27dc (patch)
tree912198e5470e78af1dcdbcfbe1740fa59ef2f4f3 /cmds
parentc6120193efebf426186b24520d70ec3e4a4aeadf (diff)
downloadframeworks_base-61b09cbc027bdfe478ac79c59494953b6cea27dc.zip
frameworks_base-61b09cbc027bdfe478ac79c59494953b6cea27dc.tar.gz
frameworks_base-61b09cbc027bdfe478ac79c59494953b6cea27dc.tar.bz2
keystore: allow '\0's in keys and add guards for cplusplus.
Change-Id: I0af6ed7c5d51ce4ca39cb837e475942800cf6e2d
Diffstat (limited to 'cmds')
-rw-r--r--cmds/keystore/keystore_get.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/cmds/keystore/keystore_get.h b/cmds/keystore/keystore_get.h
index 0e7e1ae..8330f8e 100644
--- a/cmds/keystore/keystore_get.h
+++ b/cmds/keystore/keystore_get.h
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <stdint.h>
-#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -28,18 +27,21 @@
#define KEYSTORE_MESSAGE_SIZE 65535
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* This function is provided for native components to get values from keystore.
* Users are required to link against libcutils. The lengths of keys and values
* are limited to KEYSTORE_MESSAGE_SIZE. This function returns the length of
* the requested value or -1 if something goes wrong. */
-static int keystore_get(const char *key, char *value)
+static int keystore_get(const char *key, int length, char *value)
{
- int length = strlen(key);
uint8_t bytes[2] = {length >> 8, length};
uint8_t code = 'g';
int sock;
- if (length > KEYSTORE_MESSAGE_SIZE) {
+ if (length < 0 || length > KEYSTORE_MESSAGE_SIZE) {
return -1;
}
sock = socket_local_client("keystore", ANDROID_SOCKET_NAMESPACE_RESERVED,
@@ -66,4 +68,8 @@ static int keystore_get(const char *key, char *value)
return length;
}
+#ifdef __cplusplus
+}
+#endif
+
#endif