mutt/mutt-1.5.23-carriage-return.path

131 lines
4.8 KiB
SYSTEMD

---
lib.c | 12 ++++++++++++
lib.h | 1 +
ncrypt/crypt_gpgme.c | 2 +-
ncrypt/pgp.c | 24 ++++++++++++------------
pager.c | 2 +-
5 files changed, 27 insertions(+), 14 deletions(-)
--- lib.c
+++ lib.c 2017-06-13 08:15:45.319842066 +0000
@@ -875,6 +875,18 @@ int mutt_strcmp(const char *a, const cha
return strcmp(NONULL(a), NONULL(b));
}
+int mutt_strxcmp(const char *a, const char *b)
+{
+ size_t xa, xb;
+ xa = strcspn(NONULL(a), "\r\n");
+ xb = strcspn(NONULL(b), "\r\n");
+ if (xb != xa)
+ return -1;
+ if (!xa)
+ return 0;
+ return strncmp(NONULL(a), NONULL(b), xa);
+}
+
int mutt_strcasecmp(const char *a, const char *b)
{
return strcasecmp(NONULL(a), NONULL(b));
--- lib.h
+++ lib.h 2017-06-13 08:16:23.791128961 +0000
@@ -158,6 +158,7 @@ int mutt_copy_bytes(FILE *in, FILE *out,
int mutt_rx_sanitize_string(char *dest, size_t destlen, const char *src);
int mutt_strcasecmp(const char *a, const char *b);
int mutt_strcmp(const char *a, const char *b);
+int mutt_strxcmp(const char *, const char *);
int mutt_strncasecmp(const char *a, const char *b, size_t l);
int mutt_strncmp(const char *a, const char *b, size_t l);
int mutt_strcoll(const char *a, const char *b);
--- ncrypt/crypt_gpgme.c
+++ ncrypt/crypt_gpgme.c 2017-06-13 08:15:45.319842066 +0000
@@ -2294,7 +2294,7 @@ static void copy_clearsigned(gpgme_data_
if (armor_header)
{
- if (buf[0] == '\n')
+ if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n'))
armor_header = 0;
continue;
}
--- ncrypt/pgp.c
+++ ncrypt/pgp.c 2017-06-13 08:15:45.323841992 +0000
@@ -288,7 +288,7 @@ static void pgp_copy_clearsigned(FILE *f
continue;
}
- if (mutt_strcmp(buf, "-----BEGIN PGP SIGNATURE-----\n") == 0)
+ if (mutt_strxcmp(buf, "-----BEGIN PGP SIGNATURE-----\n") == 0)
break;
if (armor_header)
@@ -352,14 +352,14 @@ int pgp_application_pgp_handler(struct B
{
clearsign = 0;
- if (mutt_strcmp("MESSAGE-----\n", buf + 15) == 0)
+ if (mutt_strxcmp("MESSAGE-----\n", buf + 15) == 0)
needpass = 1;
- else if (mutt_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0)
+ else if (mutt_strxcmp("SIGNED MESSAGE-----\n", buf + 15) == 0)
{
clearsign = 1;
needpass = 0;
}
- else if (mutt_strcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
+ else if (mutt_strxcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
{
needpass = 0;
pgp_keyblock = 1;
@@ -393,9 +393,9 @@ int pgp_application_pgp_handler(struct B
fputs(buf, tmpfp);
- if ((needpass && (mutt_strcmp("-----END PGP MESSAGE-----\n", buf) == 0)) ||
- (!needpass && ((mutt_strcmp("-----END PGP SIGNATURE-----\n", buf) == 0) ||
- (mutt_strcmp("-----END PGP PUBLIC KEY BLOCK-----\n", buf) == 0))))
+ if ((needpass && (mutt_strxcmp("-----END PGP MESSAGE-----\n", buf) == 0)) ||
+ (!needpass && ((mutt_strxcmp("-----END PGP SIGNATURE-----\n", buf) == 0) ||
+ (mutt_strxcmp("-----END PGP PUBLIC KEY BLOCK-----\n", buf) == 0))))
break;
/* remember optional Charset: armor header as defined by RfC4880 */
if (mutt_strncmp("Charset: ", buf, 9) == 0)
@@ -636,11 +636,11 @@ static int pgp_check_traditional_one_bod
{
if (mutt_strncmp("-----BEGIN PGP ", buf, 15) == 0)
{
- if (mutt_strcmp("MESSAGE-----\n", buf + 15) == 0)
+ if (mutt_strxcmp("MESSAGE-----\n", buf + 15) == 0)
enc = 1;
- else if (mutt_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0)
+ else if (mutt_strxcmp("SIGNED MESSAGE-----\n", buf + 15) == 0)
sgn = 1;
- else if (mutt_strcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
+ else if (mutt_strxcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
key = 1;
}
}
@@ -1122,9 +1122,9 @@ struct Body *pgp_sign_message(struct Bod
*/
while (fgets(buffer, sizeof(buffer) - 1, pgpout) != NULL)
{
- if (mutt_strcmp("-----BEGIN PGP MESSAGE-----\n", buffer) == 0)
+ if (mutt_strxcmp("-----BEGIN PGP MESSAGE-----\n", buffer) == 0)
fputs("-----BEGIN PGP SIGNATURE-----\n", fp);
- else if (mutt_strcmp("-----END PGP MESSAGE-----\n", buffer) == 0)
+ else if (mutt_strxcmp("-----END PGP MESSAGE-----\n", buffer) == 0)
fputs("-----END PGP SIGNATURE-----\n", fp);
else
fputs(buffer, fp);
--- pager.c
+++ pager.c 2017-06-13 08:15:45.323841992 +0000
@@ -803,7 +803,7 @@ static void resolve_types(char *buf, cha
lineInfo[n].type = MT_COLOR_NORMAL;
else if (check_attachment_marker((char *) raw) == 0)
lineInfo[n].type = MT_COLOR_ATTACHMENT;
- else if ((mutt_strcmp("-- \n", buf) == 0) || (mutt_strcmp("-- \r\n", buf) == 0))
+ else if (mutt_strxcmp("-- \n", buf) == 0)
{
i = n + 1;