Lib: Don't use realloc() in keyctl_{describe,read,get_security}_alloc()

Don't use realloc() in keyctl_{describe,read,get_security}_alloc() as it
doesn't free the argument buffer if it fails and it will copy the empty buffer
if it moves it.

Use malloc+free instead.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
Fix some issues in key.dns_resolver.c:

 (1) Check the success of strtol() correctly when parsing the key ID - and
     make sure the key ID isn't blank beforehand.

 (2) buf and callout_info in main() are guaranteed to be NULL at the point
     they're tested prior to calling keyctl_describe_alloc() and
     keyctl_read_alloc() so the if-statements are redundant.

 (3) In append_address_to_payload() remove an if-statement that can never
     trigger, given the if-statement it's embedded within.

 (4) usage() doesn't know of a key ID to negate, so don't do that.

 (5) The 'key' argument to dns_query_*() is redundant given the global
     variable of the same name holding the same value.

 (6) dns_query_a_or_aaaa() declares a local variable masking the 'key'
     argument and global variable in an inner scope.

 (7) DNS_EXPIRY_PREFIX, DNS_EXPIRY_TIME_LEN and AFSDB_MAX_DATA_LEN are all
     unused and LIST_MULTIPLE_ITEMS is only set, never read, so delete them
     all.

 (8) Make append_address_to_payload() copy the argument if it's not a
     duplicate rather than copying it in the caller then discarding when we
     find out it is a duplicate.

 (9) Move vllist[] and vlsnum into afsdb_hosts_to_addrs() rather than passing
     them in from the caller where they aren't otherwise used.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Wang Lei <wang840925@gmail.com>
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>
Revert "Lib: Check the description string is NUL-terminated when retrieved"

This reverts commit ed72a1dfc56a4f5428affb1659d6812d54e392c5.

The problem is that the buffer argument might validly be NULL, leading to a
SEGV when we try to check for the NUL termination.

Signed-off-by: David Howells <dhowells@redhat.com>
Lib: Fix typo in permission mask.

The KEY_OTH_SETATTR constant macro is defined incorrectly.

Signed-off-by: James Muir <james.muir@graphitesoftware.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Doc: Move manual pages to their own subdir

Move manual pages to their own subdir to tidy the sources up.

Signed-off-by: David Howells <dhowells@redhat.com>
Doc: Add a Developer's Certificate of Origin

Add a Developer's Certificate of Origin for the use of people submitting
patches.

Signed-off-by: David Howells <dhowells@redhat.com>
Doc: Improve the keyctl_read[_alloc]() manpage

Improve the keyctl_read[_alloc]() manpage.

Signed-off-by: David Howells <dhowells@redhat.com>
Doc: Add man7 pages for various keyrings concepts

Add manual pages to section 7 describing various keyrings concepts.

Signed-off-by: David Howells <dhowells@redhat.com>
Move to version 1.5.9