X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=cgi%2Fhashquery.c;h=d750608b812342cc9160c70bc574ab73b42e0294;hb=HEAD;hp=5c056a2d3298ab3bb37769cbcd92eb1c0faae7f4;hpb=3877403043acfbfa57497d3ba51a5ec2db1c77dc;p=onak.git diff --git a/cgi/hashquery.c b/cgi/hashquery.c index 5c056a2..d750608 100644 --- a/cgi/hashquery.c +++ b/cgi/hashquery.c @@ -23,6 +23,7 @@ #include #include +#include "build-config.h" #include "charfuncs.h" #include "cleanup.h" #include "keydb.h" @@ -40,9 +41,9 @@ void doerror(char *error) exit(EXIT_FAILURE); } -int main(int argc, char *argv[]) +int main(__unused int argc, __unused char *argv[]) { - char *request_method; + char *request_method, *env; int count, found, i; uint8_t **hashes; struct buffer_ctx cgipostbuf; @@ -57,7 +58,8 @@ int main(int argc, char *argv[]) doerror("hashquery must be a HTTP POST request.\n"); } - if (!(cgipostbuf.size = atoi(getenv("CONTENT_LENGTH")))) { + env = getenv("CONTENT_LENGTH"); + if ((env == NULL) || !(cgipostbuf.size = atoi(env))) { doerror("Must provide a content length.\n"); } @@ -72,7 +74,7 @@ int main(int argc, char *argv[]) } hashes = (uint8_t **) unmarshal_array(buffer_fetchchar, &cgipostbuf, - (void * (*)(int (*)(void *, size_t, void *), void *)) + (void * (*)(size_t (*)(void *, size_t, void *), void *)) unmarshal_skshash, &count); free(cgipostbuf.buffer); @@ -92,6 +94,10 @@ int main(int argc, char *argv[]) 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."); @@ -113,7 +119,7 @@ int main(int argc, char *argv[]) puts("Content-Type: pgp/keys\n"); marshal_array(stdout_putchar, NULL, - (void (*)(int (*)(void *, size_t, void *), + (void (*)(size_t (*)(void *, size_t, void *), void *, const void *)) marshal_publickey, (void **) keys, found); printf("\n");