X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/4b8483ae278577a3adc8d84da81d77019704466f..fa2c30bab91ed66c52bc4c2fdd025602f3737d42:/add.c?ds=sidebyside diff --git a/add.c b/add.c index 323373b..95f2189 100644 --- a/add.c +++ b/add.c @@ -16,6 +16,7 @@ #include "keydb.h" #include "keystructs.h" #include "parsekey.h" +#include "merge.h" struct cgi_get_ctx { char *buffer; @@ -23,13 +24,15 @@ struct cgi_get_ctx { }; -int cgi_getchar(void *ctx, unsigned char *c) +int cgi_getchar(void *ctx, size_t count, unsigned char *c) { struct cgi_get_ctx *buf = NULL; buf = (struct cgi_get_ctx *) ctx; - *c = buf->buffer[buf->offset++]; + while (count-- > 0 && *c != 0) { + *c = buf->buffer[buf->offset++]; + } return (*c == 0); } @@ -38,7 +41,6 @@ int main(int argc, char *argv[]) { struct openpgp_packet_list *packets = NULL; struct openpgp_publickey *keys = NULL; - struct openpgp_publickey *curkey = NULL; char **params = NULL; struct cgi_get_ctx ctx; int i; @@ -49,13 +51,19 @@ int main(int argc, char *argv[]) for (i = 0; params != NULL && params[i] != NULL; i += 2) { if (!strcmp(params[i], "keytext")) { ctx.buffer = params[i+1]; + } else { + free(params[i+1]); } + params[i+1] = NULL; + free(params[i]); + params[i] = NULL; + } + if (params != NULL) { + free(params); + params = NULL; } -// puts("HTTP/1.0 200 OK"); -// puts("Server: onak 0.0.1"); - puts("Content-Type: text/html\n"); - puts("