summaryrefslogtreecommitdiffstats
path: root/cmds/keystore
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2009-09-20 10:15:46 +0800
committerChia-chi Yeh <chiachi@android.com>2009-09-21 11:36:33 +0800
commit626c46b016118edbea3a3938425b5d4e959f6f2d (patch)
tree8596e2f3dca8503f07d6eeadd9312897741b3f7c /cmds/keystore
parentc4b144533a9a5d03ee1fbcf27492a8be5737541d (diff)
downloadframeworks_base-626c46b016118edbea3a3938425b5d4e959f6f2d.zip
frameworks_base-626c46b016118edbea3a3938425b5d4e959f6f2d.tar.gz
frameworks_base-626c46b016118edbea3a3938425b5d4e959f6f2d.tar.bz2
keystore: enable delete(), scan(), exist() when keystore is locked.
Also check end-of-file explicitly.
Diffstat (limited to 'cmds/keystore')
-rw-r--r--cmds/keystore/keystore.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/cmds/keystore/keystore.c b/cmds/keystore/keystore.c
index 5007891..ec4e2a2 100644
--- a/cmds/keystore/keystore.c
+++ b/cmds/keystore/keystore.c
@@ -125,6 +125,12 @@ static int recv_message(uint8_t *message, int length)
return length;
}
+static int recv_end_of_file()
+{
+ uint8_t byte;
+ return recv(the_socket, &byte, 1, 0) == 0;
+}
+
static void send_code(int8_t code)
{
send(the_socket, &code, 1, 0);
@@ -358,7 +364,8 @@ static int8_t password()
}
if (n != NO_ERROR || blob.length != MASTER_KEY_SIZE) {
if (retry <= 0) {
- return reset();
+ reset();
+ return UNINITIALIZED;
}
return WRONG_PASSWORD + --retry;
}
@@ -421,9 +428,9 @@ static struct action {
{test, 't', 0, TEST, {0}},
{get, 'g', NO_ERROR, GET, {KEY_SIZE}},
{insert, 'i', NO_ERROR, INSERT, {KEY_SIZE, VALUE_SIZE}},
- {delete, 'd', NO_ERROR, DELETE, {KEY_SIZE}},
- {exist, 'e', NO_ERROR, EXIST, {KEY_SIZE}},
- {scan, 's', NO_ERROR, SCAN, {KEY_SIZE}},
+ {delete, 'd', 0, DELETE, {KEY_SIZE}},
+ {exist, 'e', 0, EXIST, {KEY_SIZE}},
+ {scan, 's', 0, SCAN, {KEY_SIZE}},
{reset, 'r', 0, RESET, {0}},
{password, 'p', 0, PASSWORD, {PASSWORD_SIZE, PASSWORD_SIZE}},
{lock, 'l', NO_ERROR, LOCK, {0}},
@@ -471,6 +478,9 @@ static int8_t process(int8_t code) {
return PROTOCOL_ERROR;
}
}
+ if (!recv_end_of_file()) {
+ return PROTOCOL_ERROR;
+ }
return action->run();
}