On 09/17/2015 04:55 PM, Matt Brookings wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 09/17/2015 10:52 AM, Drew Wells wrote:
I basically did a diff from 5.4.29 to 5.4.33 and implemented that diff to
5.5.0, some of it
had already been done to 5.5.0 and alot of it centered around the snprintf tidy
up's and the
string_list implementation. The attached patch does not include any of the
changes I
recently sent to the mailing list, just the changes from 5.4.[29->33].
This patch was generated from the 5.5.0 .tar.bz2, I had a look at SVN trunk and
from what I could
see, it was 5.4.34.
The trunk on Sourceforge is the current 5.5.0. The 5.4 series only appears in
the tags and branches
area now. I'll look over this patch and get it applied. Thanks for putting it
together!
And lastly for now, someone has done a lot of work in tidying up/making
safe all the calls to snprintf(), the attached patch completes this work
(I think). This patch comes after the 5.4.[29->33] patch I did.
!DSPAM:55fc0d7341552094314991!
diff -uPr vpopmail-5.5.0.orig/vpopmaild.c vpopmail-5.5.0/vpopmaild.c
--- vpopmail-5.5.0.orig/vpopmaild.c 2015-09-18 13:58:22.048093642 +0100
+++ vpopmail-5.5.0/vpopmaild.c 2015-09-18 14:08:11.117095122 +0100
@@ -429,7 +429,7 @@
return(-2);
}
-// snprintf(WriteBuf,sizeof(WriteBuf), RET_OK_MORE);
+// snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK_MORE);
// wait_write();
AuthVpw.pw_name = strdup(tmpvpw->pw_name);
@@ -460,7 +460,7 @@
logged_in = 1;
if(output_type < 2 ) {
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK_MORE);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK_MORE);
wait_write();
snprintf(WriteBuf,sizeof(WriteBuf), "vpopmail_dir_bin %s" RET_CRLF,
VPOPMAIL_DIR_BIN);
@@ -485,10 +485,10 @@
send_user_info(&AuthVpw);
- snprintf(WriteBuf, sizeof(WriteBuf), "." RET_CRLF);
+ snprintf(WriteBuf, sizeof(WriteBuf), "%s", "." RET_CRLF);
}
else
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
return(0);
}
@@ -525,7 +525,7 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
if ((ret=vadduser(TmpUser, TmpDomain, password, TmpUser, USE_POP )) < 0 ) {
snprintf(WriteBuf,sizeof(WriteBuf),RET_ERR "0.305 %s" RET_CRLF,
verror(ret));
return(-1);
@@ -564,7 +564,7 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
return(0);
}
@@ -626,7 +626,7 @@
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
wait_write();
while(fgets(ReadBuf,sizeof(ReadBuf),stdin)!=NULL ) {
@@ -751,7 +751,7 @@
if ( (ret=vauth_setpw( tmpvpw, TmpDomain )) != 0 ) {
snprintf(WriteBuf,sizeof(WriteBuf),RET_ERR "0.507 %s" RET_CRLF,
verror(ret));
} else {
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
}
return(0);
@@ -787,11 +787,11 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK_MORE);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK_MORE);
wait_write();
send_user_info(tmpvpw);
- snprintf(WriteBuf, sizeof(WriteBuf), "." RET_CRLF);
+ snprintf(WriteBuf, sizeof(WriteBuf), "%s", "." RET_CRLF);
return(0);
}
@@ -826,120 +826,79 @@
} else {
- if ( tmpvpw->pw_gid & NO_PASSWD_CHNG ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_password_change 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_password_change 0" RET_CRLF);
- }
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_password_change %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_PASSWD_CHNG ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & NO_POP ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_pop 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_pop 0" RET_CRLF);
- }
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_pop %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_POP ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & NO_WEBMAIL ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_webmail 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_webmail 0" RET_CRLF);
- }
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_webmail %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_WEBMAIL ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & NO_IMAP ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_imap 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_imap 0" RET_CRLF);
- }
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_imap %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_IMAP ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & BOUNCE_MAIL ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "bounce_mail 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "bounce_mail 0" RET_CRLF);
- }
+ snprintf(WriteBuf, sizeof(WriteBuf), "bounce_mail %d" RET_CRLF,
+ tmpvpw->pw_gid & BOUNCE_MAIL ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & NO_RELAY ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_relay 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_relay 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_relay %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_RELAY ? 1 : 0, RET_CRLF);
wait_write();
- if ( tmpvpw->pw_gid & NO_DIALUP ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_dialup 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_dialup 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_dialup %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_DIALUP ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & V_USER0 ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_0 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_0 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_0 %d" RET_CRLF,
+ tmpvpw->pw_gid & V_USER0 ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & V_USER1 ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_1 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_1 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_1 %d" RET_CRLF,
+ tmpvpw->pw_gid & V_USER1 ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & V_USER2 ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_2 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_2 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_2 %d" RET_CRLF,
+ tmpvpw->pw_gid & V_USER2 ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & V_USER3 ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_3 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_3 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "user_flag_3 %d" RET_CRLF,
+ tmpvpw->pw_gid & V_USER3 ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & NO_SMTP ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_smtp 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_smtp 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_smtp %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_SMTP ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & QA_ADMIN ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "domain_admin_privileges 1"
RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "domain_admin_privileges 0"
RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "domain_admin_privileges %d" RET_CRLF,
+ tmpvpw->pw_gid & QA_ADMIN ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & V_OVERRIDE ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "override_domain_limits 1"
RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "override_domain_limits 0"
RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "override_domain_limits %d" RET_CRLF,
+ tmpvpw->pw_gid & V_OVERRIDE ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & NO_SPAMASSASSIN ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_spamassassin 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_spamassassin 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_spamassassin %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_SPAMASSASSIN ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & DELETE_SPAM ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "delete_spam 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "delete_spam 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "delete_spam %d" RET_CRLF,
+ tmpvpw->pw_gid & DELETE_SPAM ? 1 : 0);
wait_write();
- if ( tmpvpw->pw_gid & NO_MAILDROP ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_maildrop 1" RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "no_maildrop 0" RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "no_maildrop %d" RET_CRLF,
+ tmpvpw->pw_gid & NO_MAILDROP);
wait_write();
- if ( tmpvpw->pw_gid & SA_ADMIN ) {
- snprintf(WriteBuf, sizeof(WriteBuf), "system_admin_privileges 1"
RET_CRLF);
- } else {
- snprintf(WriteBuf, sizeof(WriteBuf), "system_admin_privileges 0"
RET_CRLF);
- }
+
+ snprintf(WriteBuf, sizeof(WriteBuf), "system_admin_privileges %d" RET_CRLF,
+ tmpvpw->pw_gid & SA_ADMIN ? 1 : 0);
wait_write();
}
- snprintf(WriteBuf, sizeof(WriteBuf), "." RET_CRLF);
+ snprintf(WriteBuf, sizeof(WriteBuf), "%s", "." RET_CRLF);
}
@@ -983,7 +942,7 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
return(0);
}
@@ -1032,7 +991,7 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
return(0);
}
@@ -1081,7 +1040,7 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
return(0);
}
@@ -1125,7 +1084,7 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
return(0);
}
@@ -1166,7 +1125,7 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
return(0);
}
@@ -1194,7 +1153,7 @@
/* Clear the domain info cache */
vget_assign(dummy, NULL, 0, NULL, NULL );
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK);
return(0);
}
@@ -1229,7 +1188,7 @@
}
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK_MORE);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK_MORE);
wait_write();
string_list_init(&aliases, 10);
@@ -1267,7 +1226,7 @@
string_list_free(&aliases);
- snprintf(WriteBuf, sizeof(WriteBuf), "." RET_CRLF);
+ snprintf(WriteBuf, sizeof(WriteBuf), "%s", "." RET_CRLF);
return(0);
}
@@ -1718,7 +1677,7 @@
return(-1);
}
- snprintf(WriteBuf,sizeof(WriteBuf), RET_OK_MORE);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_OK_MORE);
wait_write();
count = 0;
@@ -2236,7 +2195,7 @@
if (vauth_module_feature("IP_ALIAS_DOMAINS")) {
if ( vdel_ip_map(ip,domain) < 0 ) {
- snprintf(WriteBuf,sizeof(WriteBuf), RET_ERR "0.3204 error" RET_CRLF);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", RET_ERR "0.3204 error" RET_CRLF);
return(-1);
}
@@ -2323,66 +2282,26 @@
snprintf(WriteBuf,sizeof(WriteBuf), "default_maxmsgcount %llu" RET_CRLF,
mylimits.defaultmaxmsgcount); wait_write();
- if (mylimits.disable_pop)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_pop 1" RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_pop 0" RET_CRLF);
-
- wait_write();
-
- if (mylimits.disable_imap)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_imap 1" RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_imap 0" RET_CRLF);
- wait_write();
-
- if (mylimits.disable_dialup)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_dialup 1" RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_dialup 0" RET_CRLF);
- wait_write();
-
- if (mylimits.disable_passwordchanging)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_password_changing 1"
RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_password_changing 0"
RET_CRLF);
- wait_write();
-
- if (mylimits.disable_webmail)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_webmail 1" RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_webmail 0" RET_CRLF);
- wait_write();
-
- if (mylimits.disable_relay)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_external_relay 1"
RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_external_relay 0"
RET_CRLF);
- wait_write();
-
- if (mylimits.disable_smtp)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_smtp 1" RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_smtp 0" RET_CRLF);
- wait_write();
-
- if (mylimits.disable_spamassassin)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_spamassassin 1"
RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_spamassassin 0"
RET_CRLF);
- wait_write();
-
- if (mylimits.delete_spam)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "delete_spam 1" RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "delete_spam 0" RET_CRLF);
- wait_write();
-
- if (mylimits.disable_maildrop)
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_maildrop 1" RET_CRLF);
- else
- snprintf(WriteBuf,sizeof(WriteBuf), "%s", "disable_maildrop 0" RET_CRLF);
- wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_pop %d" RET_CRLF,
+ mylimits.disable_pop ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_imap %d" RET_CRLF,
+ mylimits.disable_imap ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_dialup %d" RET_CRLF,
+ mylimits.disable_dialup ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_password_changing %d" RET_CRLF,
+ mylimits.disable_passwordchanging ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_webmail %d" RET_CRLF,
+ mylimits.disable_webmail ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_external_relay %d" RET_CRLF,
+ mylimits.disable_relay ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_smtp %d" RET_CRLF,
+ mylimits.disable_smtp ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_spamassassin %d" RET_CRLF,
+ mylimits.disable_spamassassin ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "delete_spam %d" RET_CRLF,
+ mylimits.delete_spam ? 1 : 0); wait_write();
+ snprintf(WriteBuf,sizeof(WriteBuf), "disable_maildrop %d" RET_CRLF,
+ mylimits.disable_maildrop ? 1 : 0); wait_write();
snprintf(WriteBuf,sizeof(WriteBuf), "perm_account %d" RET_CRLF,
mylimits.perm_account); wait_write();
@@ -2789,7 +2708,7 @@
wait_write();
}
}
- snprintf(WriteBuf,sizeof(WriteBuf), "." RET_CRLF);
+ snprintf(WriteBuf,sizeof(WriteBuf), "%s", "." RET_CRLF);
return(1);
}