]> granicus.if.org Git - neomutt/commitdiff
rfc822_valid_msgid
authorRichard Russon <rich@flatcap.org>
Tue, 11 Apr 2017 18:25:03 +0000 (19:25 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 12 Apr 2017 01:01:42 +0000 (02:01 +0100)
pop_auth.c
rfc822.c
rfc822.h
send.c

index 46013d67dfe93e4c826da393ceaf7ce728d50457..5cb2255e85a50ae2fdf425b4a38fa15c31205714 100644 (file)
@@ -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);
index ee09d0df5d246e4d38fa2eac1955b306680fec39..b95e6fd716bc0fc2779b4830a6080126724b3885 100644 (file)
--- 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) /* <atom@atom> */
-    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
index 7c768c2e3db1b68f3b369845ee2edd19dbb19ace..253112795d800d2fd3f1c32b8da664033f88f807 100644 (file)
--- 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 f19d134b6f1ee65b3aa266670a1ea68564191335..6689c72d100e8c7043405290d67280f203284609 100644 (file)
--- 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;