]> the.earth.li Git - onak.git/blobdiff - keydctl.c
Fix keyd memory leak on error reading client provided search text
[onak.git] / keydctl.c
index 5a2ac212b96be129cab52b173b48d8737e26757a..ef942dbd92d78635d1b31b5f6a78ccd021fc7ddf 100644 (file)
--- a/keydctl.c
+++ b/keydctl.c
@@ -32,7 +32,7 @@
 #include "version.h"
 
 /* HACK: We need to stop onak-conf.o requiring this. */
-void *DBFUNCS = NULL;
+void *DBINIT = NULL;
 
 static int keyd_fd = -1;
 static int verbose = 0;
@@ -154,23 +154,33 @@ static void keyd_status(void)
        uint32_t reply;
        struct keyd_stats stats;
 
-       keyd_do_command(KEYD_CMD_VERSION, &reply, sizeof(reply));
+       if (keyd_do_command(KEYD_CMD_VERSION, &reply, sizeof(reply)) == -1) {
+               printf("Got failure asking for keyd version.\n");
+               return;
+       }
        printf("Using keyd protocol version %d.\n", reply);
 
-       keyd_do_command(KEYD_CMD_STATS, &stats, sizeof(stats));
+       if (keyd_do_command(KEYD_CMD_STATS, &stats, sizeof(stats)) == -1) {
+               printf("Got failure asking for keyd statistics.\n");
+               return;
+       }
+
        printf("keyd running since %s", ctime(&stats.started));
        printf("%d client connections received\n", stats.connects);
 
        printf("Command statistics:\n");
        printf("  Version:          %d\n",
                stats.command_stats[KEYD_CMD_VERSION]);
-       printf("  Get key:          %d\n", stats.command_stats[KEYD_CMD_GET]);
+       printf("  Get key by ID:    %d\n",
+               stats.command_stats[KEYD_CMD_GET_ID]);
+       printf("  Get key by FP:    %d\n",
+               stats.command_stats[KEYD_CMD_GET_FP]);
        printf("  Store key:        %d\n",
                stats.command_stats[KEYD_CMD_STORE]);
        printf("  Delete key:       %d\n",
                stats.command_stats[KEYD_CMD_DELETE]);
        printf("  Search key:       %d\n",
-               stats.command_stats[KEYD_CMD_GETTEXT]);
+               stats.command_stats[KEYD_CMD_GET_TEXT]);
        printf("  Get full keyid:   %d\n",
                stats.command_stats[KEYD_CMD_GETFULLKEYID]);
        printf("  Iterate all keys: %d\n",