]> the.earth.li Git - onak.git/commitdiff
Don't store a key if we can't get the keyid
authorJonathan McDowell <noodles@earth.li>
Sat, 2 Nov 2013 05:00:25 +0000 (22:00 -0700)
committerJonathan McDowell <noodles@earth.li>
Sat, 2 Nov 2013 05:03:25 +0000 (22:03 -0700)
If the get_keyid call fails for a key then we shouldn't be storing it,
so don't.

keydb_db4.c
keydb_file.c
keydb_fs.c
keydb_keyd.c
keydb_pg.c

index 0507511ea90098ff2df788b51969b88c70c7ea9a..f4fffa58849b90e7c5f4f0cc93e28b05f29d1300 100644 (file)
@@ -1180,7 +1180,10 @@ static int db4_store_key(struct openpgp_publickey *publickey, bool intrans,
        bool       deadlock = false;
        struct skshash hash;
 
-       get_keyid(publickey, &keyid);
+       if (get_keyid(publickey, &keyid) != ONAK_E_OK) {
+               logthing(LOGTHING_ERROR, "Couldn't find key ID for key.");
+               return 0;
+       }
 
        if (!intrans) {
                db4_starttrans();
index 65e71f559d409b28bb7a9d341f398412788f6eef..4321a682ee762e4c51855858fb746851a0ed0fa2 100644 (file)
@@ -130,7 +130,10 @@ static int file_store_key(struct openpgp_publickey *publickey, bool intrans,
        int fd = -1;
        uint64_t keyid;
 
-       get_keyid(publickey, &keyid);
+       if (get_keyid(publickey, &keyid) != ONAK_E_OK) {
+               logthing(LOGTHING_ERROR, "Couldn't find key ID for key.");
+               return 0;
+       }
        snprintf(keyfile, 1023, "%s/0x%" PRIX64, config.db_dir,
                        keyid & 0xFFFFFFFF);
        fd = open(keyfile, O_WRONLY | O_CREAT, 0664); // | O_EXLOCK);
index eacf1c65b15cf1dae48c79e9e59f52503655f873..b7117bebab4ffeda8f4bf36a2b650eb3c600a256 100644 (file)
@@ -336,7 +336,10 @@ static int fs_store_key(struct openpgp_publickey *publickey, bool intrans,
        uint32_t hashid;
        int i = 0;
 
-       get_keyid(publickey, &keyid);
+       if (get_keyid(publickey, &keyid) != ONAK_E_OK) {
+               logthing(LOGTHING_ERROR, "Couldn't find key ID for key.");
+               return 0;
+       }
 
        if (!intrans)
                fs_starttrans();
index 26f2f2797a1465627a195983f221953a0c8d0fff..4820ee31d9a0a364f0e15f7670dedaf0767a98e8 100644 (file)
@@ -274,7 +274,10 @@ static int keyd_store_key(struct openpgp_publickey *publickey, bool intrans,
        uint32_t                    cmd = KEYD_CMD_STORE;
        uint64_t                    keyid;
 
-       get_keyid(publickey, &keyid);
+       if (get_keyid(publickey, &keyid) != ONAK_E_OK) {
+               logthing(LOGTHING_ERROR, "Couldn't find key ID for key.");
+               return 0;
+       }
        
        if (update) {
                keyd_delete_key(keyid, false);
index 1ec0a1a570e16fb0c71397a7055b2207dc213944..480f1f1d34541831c6e3fd414785867d0a2c3ed1 100644 (file)
@@ -376,7 +376,10 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans,
                PQclear(result);
        }
 
-       get_keyid(publickey, &keyid);
+       if (get_keyid(publickey, &keyid) != ONAK_E_OK) {
+               logthing(LOGTHING_ERROR, "Couldn't find key ID for key.");
+               return 0;
+       }
 
        /*
         * Delete the key if we already have it.