X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_keyd.c;h=d05c7f8998e2008455ce20fa6d27eb717936a075;hb=1a084272fd5c603f318d2c4dc0c70b2de0606f04;hp=5fd084398d048568df01867785f24453c93304a4;hpb=8e0907be1d73011075a99a0c029c56664e12843e;p=onak.git diff --git a/keydb_keyd.c b/keydb_keyd.c index 5fd0843..d05c7f8 100644 --- a/keydb_keyd.c +++ b/keydb_keyd.c @@ -116,7 +116,7 @@ static int keyd_fetch_key_id(struct onak_dbctx *dbctx, } static int keyd_fetch_key_fp(struct onak_dbctx *dbctx, - uint8_t *fp, size_t fpsize, + struct openpgp_fingerprint *fingerprint, struct openpgp_publickey **publickey, bool intrans) { @@ -128,16 +128,16 @@ static int keyd_fetch_key_fp(struct onak_dbctx *dbctx, ssize_t count = 0; uint8_t size; - if (fpsize > MAX_FINGERPRINT_LEN) { + if (fingerprint->length > MAX_FINGERPRINT_LEN) { return 0; } write(keyd_fd, &cmd, sizeof(cmd)); read(keyd_fd, &cmd, sizeof(cmd)); if (cmd == KEYD_REPLY_OK) { - size = fpsize; + size = fingerprint->length; write(keyd_fd, &size, sizeof(size)); - write(keyd_fd, fp, size); + write(keyd_fd, fingerprint->fp, size); keybuf.offset = 0; read(keyd_fd, &keybuf.size, sizeof(keybuf.size)); if (keybuf.size > 0) { @@ -489,7 +489,6 @@ static void keyd_cleanupdb(struct onak_dbctx *dbctx) logthing(LOGTHING_NOTICE, "Error closing down socket: %d", errno); } - keyd_fd = -1; free(dbctx); @@ -559,6 +558,13 @@ struct onak_dbctx *keydb_keyd_init(bool readonly) } count = read(keyd_fd, &reply, sizeof(reply)); + if (count != sizeof(reply)) { + logthing(LOGTHING_CRITICAL, + "Error! Unexpected keyd version " + "length: %d != %d", + count, sizeof(reply)); + exit(EXIT_FAILURE); + } logthing(LOGTHING_DEBUG, "keyd protocol version %d", reply);