diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2017-12-28 20:51:28 +0000 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2017-12-28 21:03:52 +0000 |
commit | a05d3e341fae03426a9caa9c5e9ce8fe60e3d384 (patch) | |
tree | 47c9a806b44e08709ee4ea12dcc5949b653db481 /src | |
parent | 44de51a174765f7f5ecb250638cdb3fe64ec67dc (diff) |
DKIM: tighter checking while parsing signature headers. Bug 2217
Diffstat (limited to 'src')
-rw-r--r-- | src/src/pdkim/pdkim.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/src/pdkim/pdkim.c b/src/src/pdkim/pdkim.c index 20366a461..b884671da 100644 --- a/src/src/pdkim/pdkim.c +++ b/src/src/pdkim/pdkim.c @@ -490,7 +490,12 @@ for (p = raw_hdr; ; p++) if (c == ';' || c == '\0') { - if (cur_tag && cur_val) + /* We must have both tag and value, and tags must be one char except + for the possibility of "bh". */ + + if ( cur_tag && cur_val + && (cur_tag->ptr == 1 || *cur_tag->s == 'b') + ) { (void) string_from_gstring(cur_val); pdkim_strtrim(cur_val); @@ -500,8 +505,14 @@ for (p = raw_hdr; ; p++) switch (*cur_tag->s) { case 'b': - pdkim_decode_base64(cur_val->s, - cur_tag->s[1] == 'h' ? &sig->bodyhash : &sig->sighash); + switch (cur_tag->s[1]) + { + case '\0': pdkim_decode_base64(cur_val->s, &sig->sighash); break; + case 'h': if (cur_tag->ptr == 2) + pdkim_decode_base64(cur_val->s, &sig->bodyhash); + break; + default: break; + } break; case 'v': /* We only support version 1, and that is currently the |