mutt: Return to pager upon aborting a jump operation. (closes #3...

2016-11-29 Thread Brendan Cully
changeset: 6878:d72caeecf4af
user:  Kevin McCarthy 
date:  Tue Nov 29 17:48:33 2016 -0800
link:  http://dev.mutt.org/hg/mutt/rev/d72caeecf4af

Return to pager upon aborting a jump operation. (closes #3901)

diffs (18 lines):

diff -r 1196c859942e -r d72caeecf4af curs_main.c
--- a/curs_main.c   Tue Nov 29 17:44:37 2016 -0800
+++ b/curs_main.c   Tue Nov 29 17:48:33 2016 -0800
@@ -831,7 +831,14 @@
buf[0] = 0;
if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
|| !buf[0])
+{
+  if (menu->menu == MENU_PAGER)
+  {
+op = OP_DISPLAY_MESSAGE;
+continue;
+  }
  break;
+}
 
if (mutt_atoi (buf, ) < 0)
{


Re: [Mutt] #3901: A canceled jump to message returns to index instead of staying in pager

2016-11-29 Thread Mutt
#3901: A canceled jump to message returns to index instead of staying in pager
-+--
  Reporter:  vinc17  |  Owner:  mutt-dev
  Type:  defect  | Status:  closed
  Priority:  minor   |  Milestone:
 Component:  user interface  |Version:  1.7.1
Resolution:  fixed   |   Keywords:
-+--
Changes (by Kevin McCarthy ):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"d72caeecf4af162b78fcabee2abfd0d7d62e6b07"
 6878:d72caeecf4af]:
 {{{
 #!CommitTicketReference repository=""
 revision="d72caeecf4af162b78fcabee2abfd0d7d62e6b07"
 Return to pager upon aborting a jump operation. (closes #3901)
 }}}

--
Ticket URL: 
Mutt 
The Mutt mail user agent



Re: [Mutt] #3899: mutt_ssl's interactive_check_cert() has several issues

2016-11-29 Thread Mutt
#3899: mutt_ssl's interactive_check_cert() has several issues
---+--
  Reporter:  kevin8t8  |  Owner:  mutt-dev
  Type:  defect| Status:  closed
  Priority:  major |  Milestone:
 Component:  crypto|Version:
Resolution:  fixed |   Keywords:
---+--

Comment (by Kevin McCarthy ):

 In [changeset:"1196c859942e393d353c8df77d680c7a44e76389"
 6877:1196c859942e]:
 {{{
 #!CommitTicketReference repository=""
 revision="1196c859942e393d353c8df77d680c7a44e76389"
 Add mutt_array_size macro, change interactive_check_cert() to use it.
 (see #3899)

 While I have reservations about the construct, it does make the
 interactive_check_cert() menu->max and part loop less fragile.
 }}}

--
Ticket URL: 
Mutt 
The Mutt mail user agent



mutt: 2 new changesets

2016-11-29 Thread Brendan Cully
changeset: 6876:1a2dc7b21b5b
user:  Kevin McCarthy 
date:  Tue Nov 29 17:44:31 2016 -0800
link:  http://dev.mutt.org/hg/mutt/rev/1a2dc7b21b5b

Improve openssl interactive_check_cert. (closes #3899)

Don't use X509_NAME_oneline() with a fixed size buffer, which could
truncate the string, perhaps leaving off the CN field entirely.
Instead, work directly off the X509_NAME.

Rather than use strstr to tokenize it, call
X509_NAME_get_text_by_NID() with the nid types.  Although
X509_NAME_get_text_by_NID() is "legacy", it is the most directly
useful for mutt in this simple interactive prompt.

The function was set up to include the ST and C fields in the prompt,
but the loop limit was too low.  I believe this was an oversight, so
increase the loop to include those two fields.

changeset: 6877:1196c859942e
user:  Kevin McCarthy 
date:  Tue Nov 29 17:44:37 2016 -0800
link:  http://dev.mutt.org/hg/mutt/rev/1196c859942e

Add mutt_array_size macro, change interactive_check_cert() to use it.  (see 
#3899)

While I have reservations about the construct, it does make the
interactive_check_cert() menu->max and part loop less fragile.

diffs (109 lines):

diff -r 84ad86e8b8ab -r 1196c859942e lib.h
--- a/lib.h Sat Nov 26 00:57:42 2016 +0100
+++ b/lib.h Tue Nov 29 17:44:37 2016 -0800
@@ -84,6 +84,10 @@
 # define MAX(a,b) ((a) < (b) ? (b) : (a))
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
 
+/* Use this with care.  If the compiler can't see the array
+ * definition, it obviously won't produce a correct result. */
+#define mutt_array_size(x)  (sizeof (x) / sizeof ((x)[0]))
+
 /* For mutt_format_string() justifications */
 /* Making left 0 and center -1 is of course completely nonsensical, but
  * it retains compatibility for any patches that call mutt_format_string.
diff -r 84ad86e8b8ab -r 1196c859942e mutt_ssl.c
--- a/mutt_ssl.cSat Nov 26 00:57:42 2016 +0100
+++ b/mutt_ssl.cTue Nov 29 17:44:37 2016 -0800
@@ -558,24 +558,13 @@
 }
 
 
-static char *x509_get_part (char *line, const char *ndx)
+static char *x509_get_part (X509_NAME *name, int nid)
 {
   static char ret[SHORT_STRING];
-  char *c, *c2;
 
-  strfcpy (ret, _("Unknown"), sizeof (ret));
-
-  c = strstr (line, ndx);
-  if (c)
-  {
-c += strlen (ndx);
-c2 = strchr (c, '/');
-if (c2)
-  *c2 = '\0';
-strfcpy (ret, c, sizeof (ret));
-if (c2)
-  *c2 = '/';
-  }
+  if (!name ||
+  X509_NAME_get_text_by_NID (name, nid, ret, sizeof (ret)) < 0)
+strfcpy (ret, _("Unknown"), sizeof (ret));
 
   return ret;
 }
@@ -1011,17 +1000,24 @@
 
 static int interactive_check_cert (X509 *cert, int idx, int len)
 {
-  static const char * const part[] =
-{"/CN=", "/Email=", "/O=", "/OU=", "/L=", "/ST=", "/C="};
+  static const int part[] =
+{ NID_commonName, /* CN */
+  NID_pkcs9_emailAddress, /* Email */
+  NID_organizationName,   /* O */
+  NID_organizationalUnitName, /* OU */
+  NID_localityName,   /* L */
+  NID_stateOrProvinceName,/* ST */
+  NID_countryName /* C */ };
+  X509_NAME *x509_subject;
+  X509_NAME *x509_issuer;
   char helpstr[LONG_STRING];
   char buf[STRING];
   char title[STRING];
   MUTTMENU *menu = mutt_new_menu (MENU_GENERIC);
   int done, row, i;
   FILE *fp;
-  char *name = NULL, *c;
 
-  menu->max = 19;
+  menu->max = mutt_array_size (part) * 2 + 9;
   menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *));
   for (i = 0; i < menu->max; i++)
 menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char));
@@ -1029,25 +1025,18 @@
   row = 0;
   strfcpy (menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING);
   row++;
-  name = X509_NAME_oneline (X509_get_subject_name (cert),
-   buf, sizeof (buf));
-
-  for (i = 0; i < 5; i++)
-  {
-c = x509_get_part (name, part[i]);
-snprintf (menu->dialog[row++], SHORT_STRING, "   %s", c);
-  }
+  x509_subject = X509_get_subject_name (cert);
+  for (i = 0; i < mutt_array_size (part); i++)
+snprintf (menu->dialog[row++], SHORT_STRING, "   %s",
+  x509_get_part (x509_subject, part[i]));
 
   row++;
   strfcpy (menu->dialog[row], _("This certificate was issued by:"), 
SHORT_STRING);
   row++;
-  name = X509_NAME_oneline (X509_get_issuer_name (cert),
-   buf, sizeof (buf));
-  for (i = 0; i < 5; i++)
-  {
-c = x509_get_part (name, part[i]);
-snprintf (menu->dialog[row++], SHORT_STRING, "   %s", c);
-  }
+  x509_issuer = X509_get_issuer_name (cert);
+  for (i = 0; i < mutt_array_size (part); i++)
+snprintf (menu->dialog[row++], SHORT_STRING, "   %s",
+  x509_get_part (x509_issuer, part[i]));
 
   row++;
   snprintf (menu->dialog[row++], SHORT_STRING, _("This certificate is valid"));


Re: [Mutt] #3899: mutt_ssl's interactive_check_cert() has several issues

2016-11-29 Thread Mutt
#3899: mutt_ssl's interactive_check_cert() has several issues
---+--
  Reporter:  kevin8t8  |  Owner:  mutt-dev
  Type:  defect| Status:  new
  Priority:  major |  Milestone:
 Component:  crypto|Version:
Resolution:|   Keywords:
---+--

Comment (by vinc17):

 Replying to [comment:5 vinc17]:
 > If you fear of incorrect use, one can add a check that {{{sizeof (x)}}}
 is a multiple of {{{sizeof ((x)[0])}}}, [...]

 Or better, check that {{{(void *) &(x) == (void *) &(x)[0]}}}.

--
Ticket URL: 
Mutt 
The Mutt mail user agent



Re: [Mutt] #3901: A canceled jump to message returns to index instead of staying in pager

2016-11-29 Thread Mutt
#3901: A canceled jump to message returns to index instead of staying in pager
-+--
  Reporter:  vinc17  |  Owner:  mutt-dev
  Type:  defect  | Status:  new
  Priority:  minor   |  Milestone:
 Component:  user interface  |Version:  1.7.1
Resolution:  |   Keywords:
-+--

Comment (by vinc17):

 Yes, the first patch is OK.

--
Ticket URL: 
Mutt 
The Mutt mail user agent



Re: [Mutt] #3901: A canceled jump to message returns to index instead of staying in pager

2016-11-29 Thread Mutt
#3901: A canceled jump to message returns to index instead of staying in pager
-+--
  Reporter:  vinc17  |  Owner:  mutt-dev
  Type:  defect  | Status:  new
  Priority:  minor   |  Milestone:
 Component:  user interface  |Version:  1.7.1
Resolution:  |   Keywords:
-+--
Changes (by kevin8t8):

 * Attachment "ticket-3901-v2.patch" added.


--
Ticket URL: 
Mutt 
The Mutt mail user agent



Re: [Mutt] #3899: mutt_ssl's interactive_check_cert() has several issues

2016-11-29 Thread Mutt
#3899: mutt_ssl's interactive_check_cert() has several issues
---+--
  Reporter:  kevin8t8  |  Owner:  mutt-dev
  Type:  defect| Status:  new
  Priority:  major |  Milestone:
 Component:  crypto|Version:
Resolution:|   Keywords:
---+--
Changes (by kevin8t8):

 * Attachment "ticket-3899-part2.patch" added.


--
Ticket URL: 
Mutt 
The Mutt mail user agent



Re: [Mutt] #3899: mutt_ssl's interactive_check_cert() has several issues

2016-11-29 Thread Mutt
#3899: mutt_ssl's interactive_check_cert() has several issues
---+--
  Reporter:  kevin8t8  |  Owner:  mutt-dev
  Type:  defect| Status:  new
  Priority:  major |  Milestone:
 Component:  crypto|Version:
Resolution:|   Keywords:
---+--

Comment (by kevin8t8):

 Adding a part two patch that adds a macro mutt_array_size to lib.h, and
 changes interactive_cert_check() so use it.

--
Ticket URL: 
Mutt 
The Mutt mail user agent



Re: [Mutt] #3901: A canceled jump to message returns to index instead of staying in pager

2016-11-29 Thread Mutt
#3901: A canceled jump to message returns to index instead of staying in pager
-+--
  Reporter:  vinc17  |  Owner:  mutt-dev
  Type:  defect  | Status:  new
  Priority:  minor   |  Milestone:
 Component:  user interface  |Version:  1.7.1
Resolution:  |   Keywords:
-+--
Changes (by kevin8t8):

 * Attachment "ticket-3901-v1.patch" added.


--
Ticket URL: 
Mutt 
The Mutt mail user agent