int main(int argc, char *argv[])
{
- char *request_method;
+ char *request_method, *env;
int count, found, i;
uint8_t **hashes;
struct buffer_ctx cgipostbuf;
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");
}
char **getcgivars(int argc, char *argv[])
{
int i;
- char *request_method;
+ char *request_method, *env;
int content_length, paircount;
char *cgiinput = NULL;
char **cgivars = NULL;
return NULL;
} else if (!strcmp(request_method, "GET") ||
!strcmp(request_method, "HEAD")) {
- cgiinput=strdup(getenv("QUERY_STRING"));
+ env = getenv("QUERY_STRING");
+ if (env != NULL) {
+ cgiinput = strdup(env);
+ }
} else if (!strcmp(request_method, "POST")) {
- if (getenv("CONTENT_TYPE") != NULL &&
- strcasecmp(getenv("CONTENT_TYPE"),
- "application/x-www-form-urlencoded")) {
+ env = getenv("CONTENT_TYPE");
+ if ((env != NULL) && strcasecmp(env,
+ "application/x-www-form-urlencoded")) {
printf("getcgivars(): Unsupported Content-Type.\n");
exit(1);
}
-
- if (!(content_length = atoi(getenv("CONTENT_LENGTH")))) {
+
+ env = getenv("CONTENT_LENGTH");
+ if ((env == NULL) || !(content_length = atoi(env))) {
printf("getcgivars(): No Content-Length was sent with"
" the POST request.\n");
exit(1);
}
-
- if (!(cgiinput= (char *) malloc(content_length+1))) {
+
+ if (!(cgiinput = (char *) malloc(content_length+1))) {
printf("getcgivars(): Could not malloc for "
"cgiinput.\n");
exit(1);
}
-
+
if (!fread(cgiinput, content_length, 1, stdin)) {
printf("Couldn't read CGI input from STDIN.\n");
exit(1);
exit(1);
}
+ /* If we didn't get any cgiinput info, nothing to return */
+ if (cgiinput == NULL) {
+ return NULL;
+ }
+
/* Change all plusses back to spaces */
for(i=0; cgiinput[i]; i++) if (cgiinput[i]=='+') cgiinput[i] = ' ';
return ONAK_E_UNSUPPORTED_FEATURE;
}
+ /*
+ * Keep scan-build happy; we bump this in MPI_TO_MPZ and then don't use
+ * it again the last time we do so.
+ */
+ (void)ofs;
+
key->type = pk->data[5];
if (ret != ONAK_E_OK) {
}
/* Skip to the signature material */
- ofs += 19;
+ ofs = 19;
sigkeytype = sig->data[15];
} else if (sig->data[0] >= 4) {
/* Skip the hashed data */