]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - keydb_db3.c
cscvs to tla changeset 47
[onak.git] / keydb_db3.c
index 6ef3473189de8e9060e654f0a3c0eaff2541f7c7..6177ac70f404adb0ef0764434501e64b4c194a1a 100644 (file)
@@ -21,7 +21,7 @@
 #include "charfuncs.h"
 #include "keydb.h"
 #include "keyid.h"
 #include "charfuncs.h"
 #include "keydb.h"
 #include "keyid.h"
-#include "keyindex.h"
+#include "decodekey.h"
 #include "keystructs.h"
 #include "mem.h"
 #include "onak-conf.h"
 #include "keystructs.h"
 #include "mem.h"
 #include "onak-conf.h"
@@ -99,7 +99,7 @@ void initdb(void)
        char buf[1024];
        int ret = 0;
 
        char buf[1024];
        int ret = 0;
 
-       strcpy(buf, config.db2_dbpath);
+       strcpy(buf, config.db_dir);
        strcat(buf, "/keydb.db");
        
        ret = db_create(&dbconn, NULL, 0);
        strcat(buf, "/keydb.db");
        
        ret = db_create(&dbconn, NULL, 0);
@@ -116,7 +116,7 @@ void initdb(void)
                exit(1);
        }
 
                exit(1);
        }
 
-       strcpy(buf, config.db2_dbpath);
+       strcpy(buf, config.db_dir);
        strcat(buf, "/worddb");
        
        ret = db_create(&worddb, NULL, 0);
        strcat(buf, "/worddb");
        
        ret = db_create(&worddb, NULL, 0);
@@ -217,6 +217,8 @@ int fetch_key(uint64_t keyid, struct openpgp_publickey **publickey,
                read_openpgp_stream(buffer_fetchchar, &fetchbuf,
                                &packets);
                parse_keys(packets, publickey);
                read_openpgp_stream(buffer_fetchchar, &fetchbuf,
                                &packets);
                parse_keys(packets, publickey);
+               free_packet_list(packets);
+               packets = NULL;
                numkeys++;
        } else if (ret != DB_NOTFOUND) {
                dbconn->err(dbconn, ret, "Problem retrieving key");
                numkeys++;
        } else if (ret != DB_NOTFOUND) {
                dbconn->err(dbconn, ret, "Problem retrieving key");
@@ -286,6 +288,7 @@ int fetch_key_text(const char *search, struct openpgp_publickey **publickey)
                                        llfind(keylist, data.data,
                                                worddb_cmp) != NULL) {
                                newkeylist = lladd(newkeylist, data.data);
                                        llfind(keylist, data.data,
                                                worddb_cmp) != NULL) {
                                newkeylist = lladd(newkeylist, data.data);
+                               data.data = NULL;
                        } else {
                                free(data.data);
                                data.data = NULL;
                        } else {
                                free(data.data);
                                data.data = NULL;
@@ -298,9 +301,16 @@ int fetch_key_text(const char *search, struct openpgp_publickey **publickey)
                llfree(keylist, free);
                keylist = newkeylist;
                newkeylist = NULL;
                llfree(keylist, free);
                keylist = newkeylist;
                newkeylist = NULL;
+               if (data.data != NULL) {
+                       free(data.data);
+                       data.data = NULL;
+               }
        }
        }
+       llfree(wordlist, NULL);
+       wordlist = NULL;
        
        
-       for (newkeylist = keylist; newkeylist != NULL;
+       for (newkeylist = keylist;
+                       newkeylist != NULL && numkeys < config.maxkeys;
                        newkeylist = newkeylist->next) {
 
                        keyid = 0;
                        newkeylist = newkeylist->next) {
 
                        keyid = 0;
@@ -402,6 +412,14 @@ int store_key(struct openpgp_publickey *publickey, bool intrans, bool update)
                dbconn->err(dbconn, ret, "Problem storing key");
        }
 
                dbconn->err(dbconn, ret, "Problem storing key");
        }
 
+       free(storebuf.buffer);
+       storebuf.buffer = NULL;
+       storebuf.size = 0;
+       storebuf.offset = 0; 
+
+       free_packet_list(packets);
+       packets = NULL;
+
        /*
         * Walk through our uids storing the words into the db with the keyid.
         */
        /*
         * Walk through our uids storing the words into the db with the keyid.
         */