From 76ba38d1717d6d4192be55482c28f10814eef946 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 11 Apr 2017 19:25:03 +0100 Subject: [PATCH] rfc822_valid_msgid --- pop_auth.c | 2 +- rfc822.c | 14 +++++++------- rfc822.h | 2 +- send.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pop_auth.c b/pop_auth.c index 46013d67d..5cb2255e8 100644 --- a/pop_auth.c +++ b/pop_auth.c @@ -208,7 +208,7 @@ static pop_auth_res_t pop_auth_apop (POP_DATA *pop_data, const char *method) if (!pop_data->timestamp) return POP_A_UNAVAIL; - if (rfc822_valid_msgid (pop_data->timestamp) < 0) + if (!rfc822_valid_msgid (pop_data->timestamp)) { mutt_error (_("POP timestamp is invalid!")); mutt_sleep (2); diff --git a/rfc822.c b/rfc822.c index ee09d0df5..b95e6fd71 100644 --- a/rfc822.c +++ b/rfc822.c @@ -844,7 +844,7 @@ ADDRESS *rfc822_append (ADDRESS **a, ADDRESS *b, int prune) } /* incomplete. Only used to thwart the APOP MD5 attack (#2846). */ -int rfc822_valid_msgid (const char *msgid) +bool rfc822_valid_msgid (const char *msgid) { /* msg-id = "<" addr-spec ">" * addr-spec = local-part "@" domain @@ -870,22 +870,22 @@ int rfc822_valid_msgid (const char *msgid) unsigned int l, i; if (!msgid || !*msgid) - return -1; + return false; l = mutt_strlen (msgid); if (l < 5) /* */ - return -1; + return false; if (msgid[0] != '<' || msgid[l-1] != '>') - return -1; + return false; if (!(strrchr (msgid, '@'))) - return -1; + return false; /* TODO: complete parser */ for (i = 0; i < l; i++) if ((unsigned char)msgid[i] > 127) - return -1; + return false; - return 0; + return true; } #ifdef TESTING diff --git a/rfc822.h b/rfc822.h index 7c768c2e3..253112795 100644 --- a/rfc822.h +++ b/rfc822.h @@ -57,7 +57,7 @@ int rfc822_write_address(char *buf, size_t buflen, ADDRESS *addr, int display); void rfc822_write_address_single(char *buf, size_t buflen, ADDRESS *addr, int display); void rfc822_free_address(ADDRESS **p); void rfc822_cat(char *buf, size_t buflen, const char *value, const char *specials); -int rfc822_valid_msgid(const char *msgid); +bool rfc822_valid_msgid(const char *msgid); int rfc822_remove_from_adrlist(ADDRESS **a, const char *mailbox); extern int RFC822Error; diff --git a/send.c b/send.c index f19d134b6..6689c72d1 100644 --- a/send.c +++ b/send.c @@ -359,7 +359,7 @@ static void process_user_header (ENVELOPE *env) else if (ascii_strncasecmp ("message-id:", uh->data, 11) == 0) { char *tmp = mutt_extract_message_id (uh->data + 11, NULL); - if (rfc822_valid_msgid (tmp) >= 0) + if (rfc822_valid_msgid (tmp)) { FREE(&env->message_id); env->message_id = tmp; -- 2.40.0