summaryrefslogtreecommitdiffstats
path: root/sqwebmail
diff options
context:
space:
mode:
authorSam Varshavchik2021-05-21 21:11:51 -0400
committerSam Varshavchik2021-05-21 21:11:51 -0400
commit142f42378608e593eb36ceb33895db99948427aa (patch)
treefc089285268a8fe3c8768cd7482fb50393f49354 /sqwebmail
parent34b6dbb743654fdb6edccf101c4da7e671b7a92d (diff)
downloadcourier-libs-142f42378608e593eb36ceb33895db99948427aa.tar.bz2
-Wall and -Werror fixes
Diffstat (limited to 'sqwebmail')
-rw-r--r--sqwebmail/.gitignore1
-rw-r--r--sqwebmail/ChangeLog4
-rw-r--r--sqwebmail/Makefile.am6
-rw-r--r--sqwebmail/folder.c2
-rw-r--r--sqwebmail/logindomainlist.c84
-rw-r--r--sqwebmail/testlogindomainlist.c12
-rw-r--r--sqwebmail/testlogindomainlist.sh34
-rw-r--r--sqwebmail/testlogindomainlist.txt8
8 files changed, 112 insertions, 39 deletions
diff --git a/sqwebmail/.gitignore b/sqwebmail/.gitignore
index 292956a..adc3efa 100644
--- a/sqwebmail/.gitignore
+++ b/sqwebmail/.gitignore
@@ -16,5 +16,6 @@
/sqwebmaild.dist.in
/sqwebpasswd
/testhtml
+/testlogindomainlist
/webgpg
/webmail.authpam
diff --git a/sqwebmail/ChangeLog b/sqwebmail/ChangeLog
index 2a27809..47ff451 100644
--- a/sqwebmail/ChangeLog
+++ b/sqwebmail/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-21 Sam Varshavchik <mrsam@courier-mta.com>
+
+ * Minor code tweaks, make it compleable with -Wall -Werror.
+
6.0.6
2021-02-19 Sam Varshavchik <mrsam@courier-mta.com>
diff --git a/sqwebmail/Makefile.am b/sqwebmail/Makefile.am
index d71cebf..c9d2300 100644
--- a/sqwebmail/Makefile.am
+++ b/sqwebmail/Makefile.am
@@ -27,7 +27,7 @@ noinst_DATA=$(DOCS) TIMEZONELIST
# bin_PROGRAMS in install-exec-local, otherwise make distcheck will fail.
#
-noinst_PROGRAMS=sqwebmail sqwebmaild showmsg2html testhtml
+noinst_PROGRAMS=sqwebmail sqwebmaild showmsg2html testhtml testlogindomainlist
COMMONDEPENDENCIES=$(LIBOBJS) ../pcp/libpcp.la ../maildir/libmaildir.la \
../rfc2045/librfc2045.la ../rfc822/librfc822.la \
@@ -71,7 +71,7 @@ EXTRA_DIST=$(DOCS) sqwebmail.pamconf sqwebmail-system-auth.pamconf\
sqwebmail-system-auth2.pamconf\
strdup.c strcasecmp.c strncasecmp.c sv-make_timezonelist.pl\
$(ISPELLSOURCES) \
- testhtml.tst testhtml.txt
+ testhtml.tst testhtml.txt testlogindomainlist.sh testlogindomainlist.txt
testhtml_SOURCES=testhtml.c
testhtml_LDADD=libwebmail.la
@@ -216,6 +216,8 @@ cache-reminder:
@echo '' >>sqwebmail.msg
@echo '' >>sqwebmail.msg
+testlogindomainlist_SOURCES=testlogindomainlist.c logindomainlist.c
check-am:
./testhtml <$(srcdir)/testhtml.tst | diff -U 3 $(srcdir)/testhtml.txt -
+ @SHELL@ $(srcdir)/testlogindomainlist.sh | diff -U 3 $(srcdir)/testlogindomainlist.txt -
diff --git a/sqwebmail/folder.c b/sqwebmail/folder.c
index fa2c2b1..89478b1 100644
--- a/sqwebmail/folder.c
+++ b/sqwebmail/folder.c
@@ -1615,7 +1615,7 @@ static void init_smileys(struct msg2html_info *info)
FILE *fp=open_langform(sqwebmail_content_language, "smileys.txt", 0);
char buf[1024];
- char imgbuf[1024];
+ char imgbuf[3000];
if (!fp)
return;
diff --git a/sqwebmail/logindomainlist.c b/sqwebmail/logindomainlist.c
index 050f8d4..b9f9f5c 100644
--- a/sqwebmail/logindomainlist.c
+++ b/sqwebmail/logindomainlist.c
@@ -31,13 +31,13 @@ static const char g_wc_en_mods[NUM_WC_EN_MODS][2] = { "@", "-" };
* Created : 03/03/03
* Author : JDG
* Purpose : Emulate the BSD strsep() function.
- * Notes :
- * This function is designed to emulate the BSD strsep function
- * without introducing any doubts that it is a custom
- * implementation. It's probably quite a bit slower than the
- * original BSD strsep(), but it'll do for most purposes.
- * mystrsep's functionality should be nearly identical to the
- * BSD strsep, except that it takes an int as argument for the
+ * Notes :
+ * This function is designed to emulate the BSD strsep function
+ * without introducing any doubts that it is a custom
+ * implementation. It's probably quite a bit slower than the
+ * original BSD strsep(), but it'll do for most purposes.
+ * mystrsep's functionality should be nearly identical to the
+ * BSD strsep, except that it takes an int as argument for the
* delimiter.
* -------------------------------------------------------------- */
static char *mystrsep( char **stringp, int delim )
@@ -49,16 +49,16 @@ static char *mystrsep( char **stringp, int delim )
/* Locate first occurance of delim in stringp */
*stringp=strchr(*stringp, delim);
-
+
/* If no more delimiters were found, return the last substring */
if (*stringp == NULL) return orig_stringp;
/* Set that first occurance to NUL */
**stringp='\0';
-
+
/* move pointer in front of NUL character */
++(*stringp);
-
+
/* Return original value of *stringp */
return orig_stringp;
@@ -144,7 +144,7 @@ static int ldl_invalidstatement( char *statementp )
{
const int TRUE = 1;
const int FALSE = 0;
-
+
/* comments aren't valid statements */
if (statementp[0] == '#') return TRUE;
@@ -175,7 +175,7 @@ static int ldl_invalidstatement( char *statementp )
* If the substring afterwildcardp appears at the
* absolute end of realstringp, then afterwildcardp
* is deleted from realstringp.
- *
+ *
* The string remaining in realstringp represents the
* contents of our wildcard character in
* wildcardedstringp.
@@ -189,12 +189,12 @@ static int ldl_invalidstatement( char *statementp )
* contents of realstringp with the following string:
*
* example
- *
+ *
* If no wildcard character exists in
* wildcardedstringp or if wildcardedstringp and
* realstringp don't match, extract_wildcardvalue()
* will return zero.
- *
+ *
* Otherwise, extract_wildcardvalue() returns non
* zero.
* -------------------------------------------------------------- */
@@ -210,9 +210,9 @@ static int extract_wildcardvalue( char *wildcardedstringp, char *realstringp, in
/* Copy argument to buffer so as not to modify the original. */
strcpy(wildcardedstring, wildcardedstringp);
- /* create a pointer to a pointer of a copy*/
+ /* create a pointer to a pointer of a copy*/
wildcardedstringpp = wildcardedstring;
-
+
/* tokenize wildcardstring with '\0's */
beforewildcardp=mystrsep(&wildcardedstringpp, wildcard);
@@ -240,7 +240,7 @@ static int extract_wildcardvalue( char *wildcardedstringp, char *realstringp, in
* However, this has the same effect as if we
* had somehow "deleted" beforewildcardp from
* the beginning of realstring. */
-
+
p=realstringp;
while ((*p++= *tmpp++) != 0)
@@ -301,6 +301,18 @@ static int extract_wildcardvalue( char *wildcardedstringp, char *realstringp, in
}
}
+static void cat_truncate(char *to, char *from, size_t maxn)
+{
+ size_t l=strlen(from);
+
+ if (l > maxn)
+ l=maxn;
+
+ while (*to)
+ ++to;
+ memcpy(to, from, l);
+ to[l]=0;
+}
/* --------------------------------------------------------------
* Function : replace_wildcard()
@@ -316,16 +328,16 @@ static int replace_wildcard( char *wildcardedstringp, char *wildcardvaluep, int
char *afterwildcardp;
char *wildcardedstringpp=NULL;
-
+
/* Continue only if there is actually a wildcard in wildcardedstringp */
if (ldl_haswildcard(wildcardedstringp, wildcard)) {
/* Copy wildcardedstringp so as not to modify the original. */
strcpy(wildcardedstring, wildcardedstringp);
- /* create a pointer to a pointer of a copy */
+ /* create a pointer to a pointer of a copy */
wildcardedstringpp = wildcardedstring;
-
+
/* tokenize first field */
beforewildcardp=mystrsep(&wildcardedstringpp, wildcard);
afterwildcardp=mystrsep(&wildcardedstringpp, wildcard);
@@ -341,15 +353,15 @@ static int replace_wildcard( char *wildcardedstringp, char *wildcardvaluep, int
}
/* Add wildcardvaluep string to end of wildcardedstringp */
- strncat(wildcardedstringp, wildcardvaluep,
- LINELEN-1-strlen(wildcardedstringp));
+ cat_truncate(wildcardedstringp, wildcardvaluep,
+ LINELEN-1-strlen(wildcardedstringp));
if (afterwildcardp != NULL &&
strcmp(afterwildcardp, "") != 0)
{
/* Add afterwildcardp string to end of wildcardedstringp */
- strncat(wildcardedstringp, afterwildcardp,
- LINELEN-1-strlen(wildcardedstringp));
+ cat_truncate(wildcardedstringp, afterwildcardp,
+ LINELEN-1-strlen(wildcardedstringp));
}
/* all is well */
@@ -368,12 +380,12 @@ static int replace_wildcard( char *wildcardedstringp, char *wildcardvaluep, int
* Modified : 04/07/03 by JDG
* Author : JDG
* Purpose : Retrieve default domain from 'LOGINDOMAINLIST' file
- * using either 'SERVER_ADDR' or 'HTTP_HOST' CGI
+ * using either 'SERVER_ADDR' or 'HTTP_HOST' CGI
* variables.
- * Notes :
+ * Notes :
*
* LOGINDOMAINLIST file can have the following format:
- *
+ *
* DOMAIN1:IP1:MODIFIER
* DOMAIN2:DOMAIN3:MODIFIER
* DOMAIN4:DOMAIN5:MODIFIER
@@ -430,7 +442,7 @@ static void get_defaultdomainfields( FILE *fp, char *domainp, char *modifyp)
for (count = 0; count < NUM_WC_EN_MODS; count++)
{
const char *current_modifier = &g_wc_en_mods[count][0];
-
+
/* If this record is using wildcard domain mapping... */
if (strcmp(thirdfield, current_modifier) == 0)
{
@@ -479,7 +491,7 @@ static void get_defaultdomainfields( FILE *fp, char *domainp, char *modifyp)
strcpy(finaldomain, secondfield);
}
-
+
/* seed tempbuf with contents of firstfield */
strcpy(tempbuf, firstfield);
@@ -515,7 +527,7 @@ static void get_defaultdomainfields( FILE *fp, char *domainp, char *modifyp)
}
}
-
+
/* This is reached if the third field (modifier) is NOT a wildcard */
/* compare second field against CGI variables */
if (strcmp(secondfield, serveraddr) == 0 ||
@@ -539,7 +551,7 @@ static void get_defaultdomainfields( FILE *fp, char *domainp, char *modifyp)
* Notes : none
* -------------------------------------------------------------- */
static void ldl_displayhiddenfield( char *defaultdomainp) {
-
+
if (strlen(defaultdomainp) > 0)
{
/* This is displayed only if defaultdomain is NOT
@@ -564,7 +576,7 @@ static void ldl_displayhiddenfield( char *defaultdomainp) {
* Notes : none
* -------------------------------------------------------------- */
static void ldl_displaytextfield( char *defaultdomainp) {
-
+
if (strlen(defaultdomainp) > 0)
{
/* This is displayed only if defaultdomain is NOT
@@ -594,7 +606,7 @@ static void ldl_displaytextfield( char *defaultdomainp) {
static void ldl_displaydropdown( FILE *fp, char *defaultdomainp, char *defaultgroupp) {
char buf[LINELEN];
-
+
/* This is a flag that is toggled once the first match has been
* made. */
int firstmatch=0;
@@ -650,7 +662,7 @@ static void ldl_displaydropdown( FILE *fp, char *defaultdomainp, char *defaultgr
firstfield, firstfield);
}
}
- }
+ }
}
/* Display a closing select tag only if we displayed
@@ -673,7 +685,7 @@ void print_logindomainlist( FILE *fp )
char modifierfield[LINELEN]="";
/* get default domain field and the corresponding default
- * group field (if applicable) from fp. */
+ * group field (if applicable) from fp. */
get_defaultdomainfields(fp, defaultdomain, modifierfield);
@@ -693,7 +705,7 @@ void print_logindomainlist( FILE *fp )
/* ----------------------
* DISPLAY HIDDEN FIELD
* ---------------------- */
-
+
ldl_displayhiddenfield(defaultdomain);
}
else if (strcmp(modifierfield, "-") == 0)
diff --git a/sqwebmail/testlogindomainlist.c b/sqwebmail/testlogindomainlist.c
new file mode 100644
index 0000000..9aa6fb8
--- /dev/null
+++ b/sqwebmail/testlogindomainlist.c
@@ -0,0 +1,12 @@
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "logindomainlist.h"
+
+int main(int argc, char **argv)
+{
+ print_logindomainlist(stdin);
+ return 0;
+}
diff --git a/sqwebmail/testlogindomainlist.sh b/sqwebmail/testlogindomainlist.sh
new file mode 100644
index 0000000..d76a108
--- /dev/null
+++ b/sqwebmail/testlogindomainlist.sh
@@ -0,0 +1,34 @@
+
+PROG=./testlogindomainlist
+# PROG="valgrind --tool=memcheck --vgdb-error=1 ./testlogindomainlist"
+
+cat >logindomainlist <<EOF
+courier-mta.com:host.courier-mta.com:@
+courier-mta.com:192.168.0.1:@
+EOF
+
+SERVER_ADDR=192.168.0.2 HTTP_HOST=host.courier-mta.com \
+ $PROG <logindomainlist
+echo ""
+SERVER_ADDR=192.168.0.1 HTTP_HOST=courier-mta.com \
+ $PROG <logindomainlist
+echo ""
+
+cat >logindomainlist <<EOF
+*.com:mail.*.com:@
+EOF
+
+SERVER_ADDR=192.168.0.1 HTTP_HOST=mail.courier-mta.com \
+ $PROG <logindomainlist
+echo ""
+
+cat >logindomainlist <<EOF
+courier-mta.com:host.courier-mta.com:gr
+courier-mta.net:host.courier-mta.net:gr
+courier-mta.org:host.courier-mta.org:gr
+EOF
+SERVER_ADDR=192.168.0.1 HTTP_HOST=host.courier-mta.com \
+ $PROG <logindomainlist
+echo ""
+
+rm -f logindomainlist
diff --git a/sqwebmail/testlogindomainlist.txt b/sqwebmail/testlogindomainlist.txt
new file mode 100644
index 0000000..60288c2
--- /dev/null
+++ b/sqwebmail/testlogindomainlist.txt
@@ -0,0 +1,8 @@
+<input type="hidden" name="logindomain" value="courier-mta.com" />@courier-mta.com
+<input type="hidden" name="logindomain" value="courier-mta.com" />@courier-mta.com
+<input type="hidden" name="logindomain" value="courier-mta.com" />@courier-mta.com
+@<select name="logindomain"><option value="">&nbsp;</option>
+<option value="courier-mta.com" selected="selected">courier-mta.com</option>
+<option value="courier-mta.net">courier-mta.net</option>
+<option value="courier-mta.org">courier-mta.org</option>
+</select>