Actually check the result from dbinit and exit rather than continuing
if we failed to initialise it. In particular we hit this path with a
missing config file.
}
catchsignals();
dbctx = config.dbinit(config.backend, false);
}
catchsignals();
dbctx = config.dbinit(config.backend, false);
+ if (dbctx == NULL) {
+ logthing(LOGTHING_ERROR,
+ "Failed to open key database.");
+ goto err;
+ }
+
count = cleankeys(dbctx, &keys, config.clean_policies);
logthing(LOGTHING_INFO, "%d keys cleaned.",
count);
count = cleankeys(dbctx, &keys, config.clean_policies);
logthing(LOGTHING_INFO, "%d keys cleaned.",
count);
puts("No OpenPGP packets found in input.");
end_html();
}
puts("No OpenPGP packets found in input.");
end_html();
}
cleanuplogthing();
cleanupconfig();
}
cleanuplogthing();
cleanupconfig();
}
initlogthing("gpgwww", config.logfile);
catchsignals();
dbctx = config.dbinit(config.backend, true);
initlogthing("gpgwww", config.logfile);
catchsignals();
dbctx = config.dbinit(config.backend, true);
+ if (dbctx == NULL) {
+ puts("Failed to open key database.");
+ goto err;
+ }
inithash();
logthing(LOGTHING_NOTICE, "Looking for path from 0x%016" PRIX64
" to 0x%016"
inithash();
logthing(LOGTHING_NOTICE, "Looking for path from 0x%016" PRIX64
" to 0x%016"
}
destroyhash();
dbctx->cleanupdb(dbctx);
}
destroyhash();
dbctx->cleanupdb(dbctx);
cleanuplogthing();
cleanupconfig();
cleanuplogthing();
cleanupconfig();
catchsignals();
dbctx = config.dbinit(config.backend, false);
catchsignals();
dbctx = config.dbinit(config.backend, false);
+ if (dbctx == NULL) {
+ doerror("Failed to open key database.");
+ }
+
if (dbctx->fetch_key_skshash == NULL) {
dbctx->cleanupdb(dbctx);
doerror("Can't fetch by skshash with this backend.");
if (dbctx->fetch_key_skshash == NULL) {
dbctx->cleanupdb(dbctx);
doerror("Can't fetch by skshash with this backend.");
initlogthing("lookup", config.logfile);
catchsignals();
dbctx = config.dbinit(config.backend, false);
initlogthing("lookup", config.logfile);
catchsignals();
dbctx = config.dbinit(config.backend, false);
+ if (dbctx == NULL) {
+ logthing(LOGTHING_ERROR,
+ "Failed to open key database.");
+ goto err;
+ }
switch (op) {
case OP_GET:
case OP_HGET:
switch (op) {
case OP_GET:
case OP_HGET:
puts("Unknown operation!");
}
dbctx->cleanupdb(dbctx);
puts("Unknown operation!");
}
dbctx->cleanupdb(dbctx);
cleanuplogthing();
cleanupconfig();
}
cleanuplogthing();
cleanupconfig();
}
usage();
} else if (!strcmp("dump", argv[optind])) {
dbctx = config.dbinit(config.backend, true);
usage();
} else if (!strcmp("dump", argv[optind])) {
dbctx = config.dbinit(config.backend, true);
+ if (dbctx == NULL) {
+ logthing(LOGTHING_ERROR,
+ "Failed to open key database.");
+ rc = EXIT_FAILURE;
+ goto err;
+ }
dumpstate.count = dumpstate.filenum = 0;
dumpstate.maxcount = 100000;
dumpstate.fd = -1;
dumpstate.count = dumpstate.filenum = 0;
dumpstate.maxcount = 100000;
dumpstate.fd = -1;
result);
dbctx = config.dbinit(config.backend, false);
result);
dbctx = config.dbinit(config.backend, false);
+ if (dbctx == NULL) {
+ logthing(LOGTHING_ERROR,
+ "Failed to open key database.");
+ rc = EXIT_FAILURE;
+ goto err;
+ }
result = cleankeys(dbctx, &keys,
config.clean_policies);
logthing(LOGTHING_INFO, "%d keys cleaned.",
result = cleankeys(dbctx, &keys,
config.clean_policies);
logthing(LOGTHING_INFO, "%d keys cleaned.",
}
} else if (!strcmp("clean", argv[optind])) {
dbctx = config.dbinit(config.backend, true);
}
} else if (!strcmp("clean", argv[optind])) {
dbctx = config.dbinit(config.backend, true);
+ if (dbctx == NULL) {
+ logthing(LOGTHING_ERROR,
+ "Failed to open key database.");
+ rc = EXIT_FAILURE;
+ goto err;
+ }
if (binary) {
result = read_openpgp_stream(stdin_getchar, NULL,
&packets, 0);
if (binary) {
result = read_openpgp_stream(stdin_getchar, NULL,
&packets, 0);
}
}
dbctx = config.dbinit(config.backend, false);
}
}
dbctx = config.dbinit(config.backend, false);
+ if (dbctx == NULL) {
+ logthing(LOGTHING_ERROR,
+ "Failed to open key database.");
+ rc = EXIT_FAILURE;
+ goto err;
+ }
if (!strcmp("index", argv[optind])) {
find_keys(dbctx, search, keyid, &fingerprint, ishex,
isfp, dispfp, skshash,
if (!strcmp("index", argv[optind])) {
find_keys(dbctx, search, keyid, &fingerprint, ishex,
isfp, dispfp, skshash,
cleanuplogthing();
cleanupconfig();
free(configfile);
cleanuplogthing();
cleanupconfig();
free(configfile);