summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Kistner <tom@duncanthrax.net>2009-09-09 08:13:58 +0000
committerTom Kistner <tom@duncanthrax.net>2009-09-09 08:13:58 +0000
commit97713345a45c8bd59b5290109fff8a330c89ebcf (patch)
tree892a2004c44fe01ecab19317f3616f9c2c31ff0b
parentda5dfc3ab22a3189116ea5c78927e9884529c0c0 (diff)
Forward bugfix from pdkim repo
-rw-r--r--src/src/pdkim/pdkim.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/src/pdkim/pdkim.c b/src/src/pdkim/pdkim.c
index e269f7796..55910f994 100644
--- a/src/src/pdkim/pdkim.c
+++ b/src/src/pdkim/pdkim.c
@@ -20,7 +20,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-/* $Cambridge: exim/src/src/pdkim/pdkim.c,v 1.2 2009/06/10 07:34:05 tom Exp $ */
+/* $Cambridge: exim/src/src/pdkim/pdkim.c,v 1.3 2009/09/09 08:13:58 tom Exp $ */
#include <stdlib.h>
#include <stdio.h>
@@ -162,6 +162,17 @@ pdkim_stringlist *pdkim_append_stringlist(pdkim_stringlist *base, char *str) {
}
else return new_entry;
};
+pdkim_stringlist *pdkim_prepend_stringlist(pdkim_stringlist *base, char *str) {
+ pdkim_stringlist *new_entry = malloc(sizeof(pdkim_stringlist));
+ if (new_entry == NULL) return NULL;
+ memset(new_entry,0,sizeof(pdkim_stringlist));
+ new_entry->value = strdup(str);
+ if (new_entry->value == NULL) return NULL;
+ if (base != NULL) {
+ new_entry->next = base;
+ }
+ return new_entry;
+};
/* -------------------------------------------------------------------------- */
@@ -1045,9 +1056,9 @@ int pdkim_header_complete(pdkim_ctx *ctx) {
sig->hnames_check, 1) != PDKIM_OK) goto NEXT_SIG;
}
- /* Add header to the signed headers list */
- list = pdkim_append_stringlist(sig->headers,
- ctx->cur_header->str);
+ /* Add header to the signed headers list (in reverse order) */
+ list = pdkim_prepend_stringlist(sig->headers,
+ ctx->cur_header->str);
if (list == NULL) return PDKIM_ERR_OOM;
sig->headers = list;
@@ -1347,7 +1358,8 @@ DLLEXPORT int pdkim_feed_finish(pdkim_ctx *ctx, pdkim_signature **return_signatu
q = strchr(p,':');
if (q != NULL) *q = '\0';
while (hdrs != NULL) {
- if (strncasecmp(hdrs->value,p,strlen(p)) == 0) {
+ if ( (strncasecmp(hdrs->value,p,strlen(p)) == 0) &&
+ ((hdrs->value)[strlen(p)] == ':') ) {
char *rh = NULL;
if (sig->canon_headers == PDKIM_CANON_RELAXED)
rh = pdkim_relax_header(hdrs->value,1); /* cook header for relaxed canon */
@@ -1364,6 +1376,8 @@ DLLEXPORT int pdkim_feed_finish(pdkim_ctx *ctx, pdkim_signature **return_signatu
pdkim_quoteprint(ctx->debug_stream, rh, strlen(rh), 1);
#endif
free(rh);
+ (hdrs->value)[0] = '_';
+ break;
}
hdrs = hdrs->next;
}