[neomutt-devel] [PATCH] add -Werror and -pedantic build flag; fix warnings

toogley toogley at nixnet.email
Sat Mar 6 10:51:44 CET 2021


* in smtp_auth_login() two buffers of equal sizes are used, buf and b64.
the username and the password is read into the b64 buffer and with \r\n
as separators between username and password. Therefore we reduce the
size of b64 by 2 bytes so \r\n doesn't truncate.

* use %d format for size_t loop variable
---
I'm sorry for the additional work i'm creating here but i have trouble
configuring/authentificating my github so i can't send a pull request.

Still thought this might be interesting, tests run fine locally. I can
also successfully send SMTP emails with mutt, with this change.

 Makefile.autosetup        | 2 +-
 send/smtp.c               | 2 +-
 test/hash/mutt_hash_new.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile.autosetup b/Makefile.autosetup
index a56ad81e7..3501ea748 100644
--- a/Makefile.autosetup
+++ b/Makefile.autosetup
@@ -16,7 +16,7 @@ PWD=		@PWD@
 AR=		@AR@
 CC=		@CC@
 CPP=		@CPP@
-CFLAGS=		@CPPFLAGS@ @CFLAGS@ -I. -I at srcdir@ -Wall $(EXTRA_CFLAGS)
+CFLAGS=		@CPPFLAGS@ @CFLAGS@ -I. -I at srcdir@ -Werror -pedantic -Wall $(EXTRA_CFLAGS)
 LDFLAGS=	@LDFLAGS@ $(EXTRA_LDFLAGS)
 EXEEXT=		@EXEEXT@
 LIBS=		@LIBS@
diff --git a/send/smtp.c b/send/smtp.c
index e65da7006..566c94839 100644
--- a/send/smtp.c
+++ b/send/smtp.c
@@ -631,8 +631,8 @@ static int smtp_auth_login(struct SmtpAccountData *adata, const char *method)
 {
   (void) method; // This is LOGIN
 
-  char b64[1024] = { 0 };
   char buf[1024] = { 0 };
+  char b64[1022] = { 0 }; // 2 less bytes so \r\n fits into it
 
   /* Get username and password. Bail out of any can't be retrieved. */
   if ((mutt_account_getuser(&adata->conn->account) < 0) ||
diff --git a/test/hash/mutt_hash_new.c b/test/hash/mutt_hash_new.c
index 582c54321..d72613cc9 100644
--- a/test/hash/mutt_hash_new.c
+++ b/test/hash/mutt_hash_new.c
@@ -43,7 +43,7 @@ void test_mutt_hash_new(void)
     char buf[32];
     for (size_t i = 0; i < 50; i++)
     {
-      snprintf(buf, sizeof(buf), "apple%ld", i);
+      snprintf(buf, sizeof(buf), "apple%d", i);
       mutt_hash_insert(table, buf, &dummy1);
     }
     mutt_hash_free(&table);
-- 
2.30.1



More information about the neomutt-devel mailing list