diff options
| author | Sam Varshavchik | 2021-05-21 21:11:51 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2021-05-21 21:11:51 -0400 |
| commit | 142f42378608e593eb36ceb33895db99948427aa (patch) | |
| tree | fc089285268a8fe3c8768cd7482fb50393f49354 | |
| parent | 34b6dbb743654fdb6edccf101c4da7e671b7a92d (diff) | |
| download | courier-libs-142f42378608e593eb36ceb33895db99948427aa.tar.bz2 | |
-Wall and -Werror fixes
| -rw-r--r-- | gdbmobj/configure.ac | 23 | ||||
| -rw-r--r-- | imap/ChangeLog | 4 | ||||
| -rw-r--r-- | imap/smap.c | 5 | ||||
| -rw-r--r-- | liblock/configure.ac | 10 | ||||
| -rw-r--r-- | maildir/configure.ac | 2 | ||||
| -rw-r--r-- | maildrop/configure.ac | 2 | ||||
| -rw-r--r-- | md5/configure.ac | 12 | ||||
| -rw-r--r-- | md5/md5.h | 3 | ||||
| -rw-r--r-- | rfc1035/configure.ac | 29 | ||||
| -rw-r--r-- | rfc1035/rfc1035.h | 4 | ||||
| -rw-r--r-- | rfc1035/testlookup.c | 9 | ||||
| -rw-r--r-- | rfc822/configure.ac | 9 | ||||
| -rw-r--r-- | sha1/configure.ac | 22 | ||||
| -rw-r--r-- | sha1/sha1.h | 3 | ||||
| -rw-r--r-- | soxwrap/configure.ac | 4 | ||||
| -rw-r--r-- | sqwebmail/.gitignore | 1 | ||||
| -rw-r--r-- | sqwebmail/ChangeLog | 4 | ||||
| -rw-r--r-- | sqwebmail/Makefile.am | 6 | ||||
| -rw-r--r-- | sqwebmail/folder.c | 2 | ||||
| -rw-r--r-- | sqwebmail/logindomainlist.c | 84 | ||||
| -rw-r--r-- | sqwebmail/testlogindomainlist.c | 12 | ||||
| -rw-r--r-- | sqwebmail/testlogindomainlist.sh | 34 | ||||
| -rw-r--r-- | sqwebmail/testlogindomainlist.txt | 8 | ||||
| -rw-r--r-- | tcpd/configure.ac | 6 | ||||
| -rw-r--r-- | tcpd/tcpd.c | 8 |
25 files changed, 206 insertions, 100 deletions
diff --git a/gdbmobj/configure.ac b/gdbmobj/configure.ac index ca1cb22..6dfd317 100644 --- a/gdbmobj/configure.ac +++ b/gdbmobj/configure.ac @@ -49,27 +49,4 @@ AC_SYS_LARGEFILE dnl Checks for library functions. -AC_LANG_CPLUSPLUS -AC_CACHE_CHECK([if the C++ compiler needs -fhandle-exceptions], - ac_cv_need_handlexceptions, - -AC_TRY_COMPILE([], -[ -throw; -], ac_cv_need_handlexceptions=no, -ac_cv_need_handlexceptions=yes) -) - -if test "$ac_cv_need_handlexceptions" = "yes" -then - case "$CXXFLAGS" in - *handle-exceptions*) - ;; - *) - CXXFLAGS="-fhandle-exceptions $CXXFLAGS" - CXXFLAGS=`echo "$CXXFLAGS" | sed 's/-O2//'` - ;; - esac -fi - AC_OUTPUT(Makefile) diff --git a/imap/ChangeLog b/imap/ChangeLog index c93e63b..f361e74 100644 --- a/imap/ChangeLog +++ b/imap/ChangeLog @@ -1,3 +1,7 @@ +2021-05-21 Sam Varshavchik <mrsam@courier-mta.com> + + * Minor code tweaks, make it compleable with -Wall -Werror. + 5.1.3 2021-04-01 Sam Varshavchik <mrsam@courier-mta.com> diff --git a/imap/smap.c b/imap/smap.c index 56690b3..bebf5d0 100644 --- a/imap/smap.c +++ b/imap/smap.c @@ -3245,6 +3245,7 @@ void smap() while (*(p=getword(&ptr))) { char *q=strchr(p, '='); + char *comma=q; if (q) *q++=0; @@ -3335,7 +3336,7 @@ void smap() { memset(&add_flags, 0, sizeof(add_flags)); - *--q='='; + *(q=comma)='='; parseflags(q, &add_flags); if (strchr(rights_buf, @@ -3370,7 +3371,7 @@ void smap() write_error_exit(0); } - *--q='='; + *(q=comma)='='; parsekeywords(q, &addKeywords); okmsg="KEYWORDS set"; } diff --git a/liblock/configure.ac b/liblock/configure.ac index 728ef1e..5e1745c 100644 --- a/liblock/configure.ac +++ b/liblock/configure.ac @@ -42,8 +42,8 @@ AC_CACHE_CHECK( [for off64_t], liblock_cv_hasoff64t, liblock_cv_hasoff64t="no" AC_TRY_COMPILE([ #include <sys/types.h> -],[ off64_t n; +],[ n=0; ], liblock_cv_hasoff64t="yes") @@ -72,8 +72,8 @@ AC_TRY_COMPILE([ #if HAVE_SYS_FCNTL_H #include <sys/fcntl.h> #endif -],[ flock_t t; +],[ ], liblock_cv_hasflock_t="yes")) if test "$liblock_cv_hasflock_t" = "yes" @@ -95,8 +95,8 @@ liblock_cv_hasfcntl="no" AC_TRY_LINK([ #define LL_OFFSET_TYPE $LL_OFFSET_TYPE #include "${srcdir}/lockfcntl.c" -],[ int n; +],[ ], liblock_cv_hasfcntl="yes")) if test "$liblock_cv_hasfcntl" = "yes" then @@ -109,8 +109,8 @@ liblock_cv_hasflock="no" AC_TRY_LINK([ #define LL_OFFSET_TYPE $LL_OFFSET_TYPE #include "${srcdir}/lockflock.c" -],[ int n; +],[ ], liblock_cv_hasflock="yes")) if test "$liblock_cv_hasflock" = "yes" then @@ -123,8 +123,8 @@ liblock_cv_haslockf="no" AC_TRY_LINK([ #define LL_OFFSET_TYPE $LL_OFFSET_TYPE #include "${srcdir}/locklockf.c" -],[ int n; +],[ ], liblock_cv_haslockf="yes")) if test "$liblock_cv_haslockf" = "yes" then diff --git a/maildir/configure.ac b/maildir/configure.ac index 230f35f..946954f 100644 --- a/maildir/configure.ac +++ b/maildir/configure.ac @@ -85,7 +85,7 @@ AC_TRY_COMPILE([ #include <unistd.h> #endif -extern "C" int gethostname(int,int); +extern int gethostname(int,int); ],[ ],maildir_cv_SYS_GETHOSTNAME=yes,maildir_cv_SYS_GETHOSTNAME=no ) diff --git a/maildrop/configure.ac b/maildrop/configure.ac index 50be8f9..fca57fe 100644 --- a/maildrop/configure.ac +++ b/maildrop/configure.ac @@ -268,7 +268,7 @@ AC_TRY_COMPILE([ #include <unistd.h> #endif -extern "C" int gethostname(int,int); +extern int gethostname(int,int); ],[ ],maildir_cv_SYS_GETHOSTNAME=yes,maildir_cv_SYS_GETHOSTNAME=no ) diff --git a/md5/configure.ac b/md5/configure.ac index 0f53ceb..4a90c95 100644 --- a/md5/configure.ac +++ b/md5/configure.ac @@ -35,7 +35,7 @@ dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(sys/types.h) +AC_CHECK_HEADERS(sys/types.h stdint.h) AC_ARG_WITH(int32, @@ -49,8 +49,11 @@ AC_ARG_WITH(int32, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +uint32_t i; ],[ - uint32_t i=0; ], [ AC_MSG_RESULT(yes) ; int32="uint32_t"], [ AC_MSG_RESULT(no) @@ -60,8 +63,11 @@ AC_ARG_WITH(int32, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +u_int32_t i; ],[ - u_int32_t i=0; ], [AC_MSG_RESULT(yes); int32="u_int32_t"],[ AC_MSG_RESULT(no) @@ -24,6 +24,9 @@ extern "C" { #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif #define MD5_DIGEST_SIZE 16 #define MD5_BLOCK_SIZE 64 diff --git a/rfc1035/configure.ac b/rfc1035/configure.ac index ca692c9..84b731c 100644 --- a/rfc1035/configure.ac +++ b/rfc1035/configure.ac @@ -32,7 +32,7 @@ then fi dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(sys/types.h sys/time.h unistd.h arpa/inet.h netinet/in.h strings.h) +AC_CHECK_HEADERS(sys/types.h sys/time.h unistd.h arpa/inet.h netinet/in.h strings.h stdint.h) USENSL=no saveLIBS="$LIBS" @@ -88,8 +88,11 @@ AC_ARG_WITH(int32, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +uint32_t n; ],[ - (void)(uint32_t)0; ], [ AC_MSG_RESULT(yes) ; int32="uint32_t"], [ AC_MSG_RESULT(no) @@ -99,8 +102,11 @@ AC_ARG_WITH(int32, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +u_int32_t n; ],[ - (void)(u_int32_t)0; ], [AC_MSG_RESULT(yes); int32="u_int32_t"],[ AC_MSG_RESULT(no) @@ -139,8 +145,11 @@ AC_ARG_WITH(int16, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +uint16_t n; ],[ - (void)(uint16_t)0; ], [ AC_MSG_RESULT(yes) ; int16="uint16_t"], [ AC_MSG_RESULT(no) @@ -150,8 +159,11 @@ AC_ARG_WITH(int16, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +u_int16_t n; ],[ - (void)(u_int16_t)0; ], [AC_MSG_RESULT(yes); int16="u_int16_t"],[ AC_MSG_RESULT(no) @@ -255,9 +267,9 @@ AC_TRY_COMPILE( [ #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> -] , [ struct in6_addr in6a; +] , [ in6a.s6_addr16 $LB 0 $RB =0; in6a.s6_addr32 $LB 0 $RB =0; ], @@ -268,9 +280,9 @@ AC_TRY_COMPILE( [ #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> +struct in6_addr in6a; ], [ -struct in6_addr in6a; in6a.__u6_addr.__u6_addr16 $LB 0 $RB =0; in6a.__u6_addr.__u6_addr32 $LB 0 $RB =0; @@ -282,10 +294,9 @@ AC_TRY_COMPILE( [ #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> - - ], [ struct in6_addr in6a; + ], [ in6a._S6_un._S6_u8 $LB 0 $RB = 0; in6a._S6_un._S6_u32 $LB 0 $RB = 0; diff --git a/rfc1035/rfc1035.h b/rfc1035/rfc1035.h index 9a92c1b..3c802e0 100644 --- a/rfc1035/rfc1035.h +++ b/rfc1035/rfc1035.h @@ -21,7 +21,9 @@ #if HAVE_NETINET_IN_H #include <netinet/in.h> #endif - +#if HAVE_STDINT_H +#include <stdint.h> +#endif #ifdef __cplusplus extern "C" { #endif diff --git a/rfc1035/testlookup.c b/rfc1035/testlookup.c index 75c701f..869e806 100644 --- a/rfc1035/testlookup.c +++ b/rfc1035/testlookup.c @@ -312,8 +312,13 @@ char ptrbuf[RFC1035_MAXNAMESIZE+1]; { char namebuf[RFC1035_MAXNAMESIZE+1]; - namebuf[0]=0; - strncat(namebuf, q_name, RFC1035_MAXNAMESIZE); + size_t l=strlen(q_name); + + if (l > RFC1035_MAXNAMESIZE) + l=RFC1035_MAXNAMESIZE; + + memcpy(namebuf, q_name, l); + namebuf[l]=0; if (rfc1035_resolve_cname_multiple(&res, namebuf, q_type, q_class, diff --git a/rfc822/configure.ac b/rfc822/configure.ac index 82dbdfa..a8d7efd 100644 --- a/rfc822/configure.ac +++ b/rfc822/configure.ac @@ -64,22 +64,25 @@ AC_CACHE_CHECK([how to calculate alternate timezone],librfc822_cv_SYS_TIMEZONE, AC_TRY_COMPILE([ #include <time.h> +time_t t; ],[ -time_t t=altzone; +t=altzone; ], librfc822_cv_SYS_TIMEZONE=altzone, AC_TRY_COMPILE([ #include <time.h> +int n; ],[ -int n=daylight; + n=daylight; ], librfc822_cv_SYS_TIMEZONE=daylight, AC_TRY_COMPILE([ #include <time.h> extern struct tm dummy; +long n; ],[ -long n=dummy.tm_gmtoff; + n=dummy.tm_gmtoff; ] ,librfc822_cv_SYS_TIMEZONE=tm_gmtoff, librfc822_cv_SYS_TIMEZONE=unknown ) diff --git a/sha1/configure.ac b/sha1/configure.ac index d424b26..6bc8351 100644 --- a/sha1/configure.ac +++ b/sha1/configure.ac @@ -32,7 +32,7 @@ dnl Checks for libraries. dnl Checks for header files. -AC_CHECK_HEADERS(sys/types.h) +AC_CHECK_HEADERS(sys/types.h stdint.h) AC_ARG_WITH(int32, [ --with-int32='type' use 'type' for an unsigned 32 bit integer type @@ -45,8 +45,11 @@ AC_ARG_WITH(int32, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +uint32_t i; ],[ - uint32_t i=0; ], [ AC_MSG_RESULT(yes) ; int32="uint32_t"], [ AC_MSG_RESULT(no) @@ -56,8 +59,11 @@ AC_ARG_WITH(int32, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +u_int32_t i; ],[ - u_int32_t i=0; ], [AC_MSG_RESULT(yes); int32="u_int32_t"],[ AC_MSG_RESULT(no) @@ -99,8 +105,11 @@ AC_ARG_WITH(int64, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +uint64_t i; ],[ - uint64_t i=0; ], [ AC_MSG_RESULT(yes) ; int64="uint64_t"], [ AC_MSG_RESULT(no) @@ -110,8 +119,11 @@ AC_ARG_WITH(int64, #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif +u_int64_t i; ],[ - u_int64_t i=0; ], [AC_MSG_RESULT(yes); int64="u_int64_t"],[ AC_MSG_RESULT(no) diff --git a/sha1/sha1.h b/sha1/sha1.h index 3bd397c..d63e88e 100644 --- a/sha1/sha1.h +++ b/sha1/sha1.h @@ -14,6 +14,9 @@ #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#if HAVE_STDINT_H +#include <stdint.h> +#endif #define SHA1_DIGEST_SIZE 20 #define SHA1_BLOCK_SIZE 64 diff --git a/soxwrap/configure.ac b/soxwrap/configure.ac index 0e7a319..11137fb 100644 --- a/soxwrap/configure.ac +++ b/soxwrap/configure.ac @@ -124,13 +124,13 @@ AC_TRY_COMPILE( [ #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> - - ], [ struct in6_addr in6a; struct sockaddr_in6 sain6; struct sockaddr_storage soas; int x=PF_INET6; + ], [ + ], soxwrap_cv_hasipv6structs=yes, soxwrap_cv_hasipv6structs=no ) ) 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=""> </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> diff --git a/tcpd/configure.ac b/tcpd/configure.ac index 3bc0e64..656c82c 100644 --- a/tcpd/configure.ac +++ b/tcpd/configure.ac @@ -568,11 +568,13 @@ RAND_bytes(dummy, 1); AC_TRY_COMPILE( [ #include <openssl/ssl.h> + +SSL *p; ], [ -SSL_get_servername((SSL *)0, TLSEXT_NAMETYPE_host_name); +(void)SSL_get_servername(p, TLSEXT_NAMETYPE_host_name); ], [ - AC_DEFINE_UNQUOTED(HAVE_OPENSSL_SNI,1,[ When OpenSSL supports SNI ]) + AC_DEFINE_UNQUOTED(HAVE_OPENSSL_SNI,1,[ Whether OpenSSL supports SNI ]) ]) TLSLIBRARY="$LIBCOURIERTLSOPENSSL" diff --git a/tcpd/tcpd.c b/tcpd/tcpd.c index 0fd0398..7cd3afa 100644 --- a/tcpd/tcpd.c +++ b/tcpd/tcpd.c @@ -1605,9 +1605,13 @@ static void docheckblocklist(struct blocklist_s *p, const char *nameptr) int found; unsigned char query_A[] = {RFC1035_TYPE_A, 0}, query_A_and_TXT[] = {RFC1035_TYPE_A, RFC1035_TYPE_TXT, 0}; + size_t l=strlen(nameptr); - hostname[0]=0; - strncat(hostname, nameptr, RFC1035_MAXNAMESIZE); + if (l > RFC1035_MAXNAMESIZE) + l=RFC1035_MAXNAMESIZE; + + memcpy(hostname, nameptr, l); + hostname[l]=0; if (!varname) varname="BLOCK"; |
