- if (where == PDKIM_HDR_VALUE) {
- if (cur_val == NULL)
- cur_val = pdkim_strnew(NULL);
-
- if ( (*p == '\r') || (*p == '\n') || (*p == ' ') || (*p == '\t') )
- goto NEXT_CHAR;
-
- if ( (*p == ';') || (*p == '\0') ) {
- if (cur_tag->len > 0) {
- pdkim_strtrim(cur_val);
- #ifdef PDKIM_DEBUG
- if (ctx->debug_stream)
- fprintf(ctx->debug_stream, " %s=%s\n", cur_tag->str, cur_val->str);
- #endif
- switch (cur_tag->str[0]) {
- case 'b':
- switch (cur_tag->str[1]) {
- case 'h':
- sig->bodyhash = pdkim_decode_base64(cur_val->str,&(sig->bodyhash_len));
- break;
- default:
- sig->sigdata = pdkim_decode_base64(cur_val->str,&(sig->sigdata_len));
- break;
- }
- break;
- case 'v':
- if (strcmp(cur_val->str,PDKIM_SIGNATURE_VERSION) == 0) {
- /* We only support version 1, and that is currently the
- only version there is. */
- sig->version = 1;
- }
- break;
- case 'a':
- i = 0;
- while (pdkim_algos[i] != NULL) {
- if (strcmp(cur_val->str,pdkim_algos[i]) == 0 ) {
- sig->algo = i;
- break;
- }
- i++;
- }
- break;
- case 'c':
- i = 0;
- while (pdkim_combined_canons[i].str != NULL) {
- if (strcmp(cur_val->str,pdkim_combined_canons[i].str) == 0 ) {
- sig->canon_headers = pdkim_combined_canons[i].canon_headers;
- sig->canon_body = pdkim_combined_canons[i].canon_body;
- break;
- }
- i++;
- }
- break;
- case 'q':
- i = 0;
- while (pdkim_querymethods[i] != NULL) {
- if (strcmp(cur_val->str,pdkim_querymethods[i]) == 0 ) {
- sig->querymethod = i;
- break;
- }
- i++;
- }
- break;
- case 's':
- sig->selector = strdup(cur_val->str);
- break;
- case 'd':
- sig->domain = strdup(cur_val->str);
- break;
- case 'i':
- sig->identity = pdkim_decode_qp(cur_val->str);
- break;
- case 't':
- sig->created = strtoul(cur_val->str,NULL,10);
- break;
- case 'x':
- sig->expires = strtoul(cur_val->str,NULL,10);
- break;
- case 'l':
- sig->bodylength = strtol(cur_val->str,NULL,10);
- break;
- case 'h':
- sig->headernames = strdup(cur_val->str);
- break;
- case 'z':
- sig->copiedheaders = pdkim_decode_qp(cur_val->str);
- break;
- default:
- #ifdef PDKIM_DEBUG
- if (ctx->debug_stream)
- fprintf(ctx->debug_stream, " Unknown tag encountered\n");
- #endif
- break;
- }
- }
- pdkim_strclear(cur_tag);
- pdkim_strclear(cur_val);
- in_b_val = 0;
- where = PDKIM_HDR_LIMBO;
- goto NEXT_CHAR;
+ if (where == PDKIM_HDR_VALUE)
+ {
+ if (c == '\r' || c == '\n' || c == ' ' || c == '\t')
+ goto NEXT_CHAR;
+
+ if (c == ';' || c == '\0')
+ {
+ if (tl && vl)
+ {
+ cur_val[vl] = '\0';
+ pdkim_strtrim(cur_val);
+
+ DEBUG(D_acl) debug_printf(" %s=%s\n", cur_tag, cur_val);
+
+ switch (*cur_tag)
+ {
+ case 'b':
+ pdkim_decode_base64(cur_val,
+ cur_tag[1] == 'h' ? &sig->bodyhash : &sig->sighash);
+ break;
+ case 'v':
+ /* We only support version 1, and that is currently the
+ only version there is. */
+ sig->version =
+ Ustrcmp(cur_val, PDKIM_SIGNATURE_VERSION) == 0 ? 1 : -1;
+ break;
+ case 'a':
+ for (i = 0; pdkim_algos[i]; i++)
+ if (Ustrcmp(cur_val, pdkim_algos[i]) == 0)
+ {
+ sig->algo = i;
+ break;
+ }
+ break;
+ case 'c':
+ for (i = 0; pdkim_combined_canons[i].str; i++)
+ if (Ustrcmp(cur_val, pdkim_combined_canons[i].str) == 0)
+ {
+ sig->canon_headers = pdkim_combined_canons[i].canon_headers;
+ sig->canon_body = pdkim_combined_canons[i].canon_body;
+ break;
+ }
+ break;
+ case 'q':
+ for (i = 0; pdkim_querymethods[i]; i++)
+ if (Ustrcmp(cur_val, pdkim_querymethods[i]) == 0)
+ {
+ sig->querymethod = i;
+ break;
+ }
+ break;
+ case 's':
+ sig->selector = string_copy(cur_val); break;
+ case 'd':
+ sig->domain = string_copy(cur_val); break;
+ case 'i':
+ sig->identity = pdkim_decode_qp(cur_val); break;
+ case 't':
+ sig->created = strtoul(CS cur_val, NULL, 10); break;
+ case 'x':
+ sig->expires = strtoul(CS cur_val, NULL, 10); break;
+ case 'l':
+ sig->bodylength = strtol(CS cur_val, NULL, 10); break;
+ case 'h':
+ sig->headernames = string_copy(cur_val); break;
+ case 'z':
+ sig->copiedheaders = pdkim_decode_qp(cur_val); break;
+ default:
+ DEBUG(D_acl) debug_printf(" Unknown tag encountered\n");
+ break;
+ }
+ }
+ tl = 0;
+ vl = 0;
+ in_b_val = FALSE;
+ where = PDKIM_HDR_LIMBO;