aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2014-01-29 20:25:06 +0000
committerDavid Howells <dhowells@redhat.com>2014-02-21 14:04:01 +0000
commit00feb366f80b2a56d5941092c697f924c61f056f (patch)
treebc563acbc0d8cb2ebe0896181c166f59dc9d9079
parentbe866f8a3b712da235fad874ab61536c05a9003f (diff)
downloadkeyutils-00feb366f80b2a56d5941092c697f924c61f056f.tar.gz
keyctl: Fix command table searching
In the keyctl program, when searching the command table, don't trust that an overlong argument name won't cause memcpy() to segfault. This is unlikely to be a problem as any efficient memcpy() is going to start scanning from the lowest address, given that it has to report on the lowest-addressed difference if there is one. Reported-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--keyctl.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/keyctl.c b/keyctl.c
index 7504476..7e5ce6f 100644
--- a/keyctl.c
+++ b/keyctl.c
@@ -155,6 +155,8 @@ int main(int argc, char *argv[])
for (cmd = commands; cmd->name; cmd++) {
if (!cmd->action)
continue;
+ if (strlen(cmd->name) > n)
+ continue;
if (memcmp(cmd->name, *argv, n) != 0)
continue;