diff options
author | David Howells <dhowells@redhat.com> | 2014-01-15 15:07:05 +0000 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2014-01-15 15:07:05 +0000 |
commit | a6523da06977c3ed4d288f533dc58250a4e69189 (patch) | |
tree | 541c72d829031b8f6beb7592e3947f2495435786 | |
parent | 491cdcaefc3a689e9f5c256373fef9dfd2c4c145 (diff) | |
download | keyutils-a6523da06977c3ed4d288f533dc58250a4e69189.tar.gz |
Use keyctl_describe_alloc() in dump_key_tree_aux()
Use the keyctl_describe_alloc() library function in dump_key_tree_aux() in the
keyctl program rather than open coding it.
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | keyctl.c | 21 |
1 files changed, 2 insertions, 19 deletions
@@ -1684,7 +1684,7 @@ static int dump_key_tree_aux(key_serial_t key, int depth, int more, int hex_key_ static char dumpindent[64]; key_serial_t *pk; key_perm_t perm; - size_t ringlen, desclen; + size_t ringlen; void *payload; char *desc, type[255], pretty_mask[9]; int uid, gid, ret, n, dpos, rdepth, kcount = 0; @@ -1692,30 +1692,13 @@ static int dump_key_tree_aux(key_serial_t key, int depth, int more, int hex_key_ if (depth > 8 * 4) return 0; - /* find out how big this key's description is */ - ret = keyctl_describe(key, NULL, 0); - if (ret < 0) { - printf("%d: key inaccessible (%m)\n", key); - return 0; - } - desclen = ret + 1; - - desc = malloc(desclen); - if (!desc) - error("malloc"); - /* read the description */ - ret = keyctl_describe(key, desc, desclen); + ret = keyctl_describe_alloc(key, &desc); if (ret < 0) { printf("%d: key inaccessible (%m)\n", key); - free(desc); return 0; } - desclen = ret < desclen ? ret : desclen; - - desc[desclen] = 0; - /* parse */ type[0] = 0; uid = 0; |