mutt stable branch with some hacks

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.

+7 -3
+4
lib.h
··· 84 84 # define MAX(a,b) ((a) < (b) ? (b) : (a)) 85 85 # define MIN(a,b) ((a) < (b) ? (a) : (b)) 86 86 87 + /* Use this with care. If the compiler can't see the array 88 + * definition, it obviously won't produce a correct result. */ 89 + #define mutt_array_size(x) (sizeof (x) / sizeof ((x)[0])) 90 + 87 91 /* For mutt_format_string() justifications */ 88 92 /* Making left 0 and center -1 is of course completely nonsensical, but 89 93 * it retains compatibility for any patches that call mutt_format_string.
+3 -3
mutt_ssl.c
··· 1017 1017 int done, row, i; 1018 1018 FILE *fp; 1019 1019 1020 - menu->max = 23; 1020 + menu->max = mutt_array_size (part) * 2 + 9; 1021 1021 menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *)); 1022 1022 for (i = 0; i < menu->max; i++) 1023 1023 menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char)); ··· 1026 1026 strfcpy (menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING); 1027 1027 row++; 1028 1028 x509_subject = X509_get_subject_name (cert); 1029 - for (i = 0; i < 7; i++) 1029 + for (i = 0; i < mutt_array_size (part); i++) 1030 1030 snprintf (menu->dialog[row++], SHORT_STRING, " %s", 1031 1031 x509_get_part (x509_subject, part[i])); 1032 1032 ··· 1034 1034 strfcpy (menu->dialog[row], _("This certificate was issued by:"), SHORT_STRING); 1035 1035 row++; 1036 1036 x509_issuer = X509_get_issuer_name (cert); 1037 - for (i = 0; i < 7; i++) 1037 + for (i = 0; i < mutt_array_size (part); i++) 1038 1038 snprintf (menu->dialog[row++], SHORT_STRING, " %s", 1039 1039 x509_get_part (x509_issuer, part[i])); 1040 1040