From d0695ce0c3f92b3edc7e28e77b61b4d8ebb3f352 Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Wed, 17 Feb 2021 02:54:13 +0100 Subject: [PATCH] Abandon ARC header parsing on unexpected data This change checks for null pointer and saves us a crash --- opendmarc/opendmarc-arcares.c | 2 ++ opendmarc/opendmarc-arcseal.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/opendmarc/opendmarc-arcares.c b/opendmarc/opendmarc-arcares.c index c90fd37a..015be4a4 100644 --- a/opendmarc/opendmarc-arcares.c +++ b/opendmarc/opendmarc-arcares.c @@ -324,6 +324,8 @@ opendmarc_arcares_arc_parse (u_char *hdr_arc, struct arcares_arc_field *arc) if (*token_ptr == '\0') return 0; tag_label = strsep(&token_ptr, "="); + if (token_ptr == NULL) + return -1; tag_value = opendmarc_arcares_strip_whitespace(token_ptr); tag_code = opendmarc_arcares_convert(aar_arc_tags, tag_label); diff --git a/opendmarc/opendmarc-arcseal.c b/opendmarc/opendmarc-arcseal.c index f12512c8..51dee764 100644 --- a/opendmarc/opendmarc-arcseal.c +++ b/opendmarc/opendmarc-arcseal.c @@ -223,7 +223,11 @@ opendmarc_arcseal_parse(u_char *hdr, struct arcseal *as) if (*token_ptr == '\0') return 0; tag_label = strsep(&token_ptr, "="); + if (token_ptr == NULL) + return -1; tag_value = opendmarc_arcseal_strip_whitespace(token_ptr); + if (tag_value == NULL) + return -1; tag_code = opendmarc_arcseal_convert(as_tags, tag_label);