diff --git a/.RELEASE.NOTES b/.RELEASE.NOTES index 47d699ecc..6b5cacd4f 100644 --- a/.RELEASE.NOTES +++ b/.RELEASE.NOTES @@ -1,5 +1,5 @@ -Unreal3.2-Selene (BETA7) RELEASE NOTES +Unreal3.2-Selene (BETA10) RELEASE NOTES ====================================== I M P O R T A N T R E A D I N G diff --git a/Changes b/Changes index ea3af138f..0bb7c9a5c 100644 --- a/Changes +++ b/Changes @@ -1257,3 +1257,43 @@ seen. gmtime warning still there - Added EXLIBS= to make custommodule so a module can specify additional libraries it needs - Changed version to beta9 and updated documentation - Made +I once again work in win32 +*** beta9 released *** +- Fixed a stupid m_oper bug +- Fixed a win32 editor bug causing a crash when you click save multiple times +- Fixed a /stats q bug where it would crash if there was an sqline with no reason, reported by toji (#0000120) +- Fixed a bug that caused locops to see client exiting but not client connecting notices while +s +c, + reported and fixed by cmx (#0000123) +- Fixed a bug reported by dimplesx where +H did not decrease the oper count (#0000129) +- Documentation bug #0000152 reported by Tony at sexnet.org fixed regarding + example.conf being wrong about set::socks +- First part of skyper's security audit patch +- Some more of skyper's security audit patch. Some of them were simply + unfair in regards to performance or blindly added strlcats/strlcpy +- Fixed some problems with skyper's patch (typos) +- Fixed a cloak problem on OSes with 64bit integers (reported by wolven) +- Updated credits +- Memory leak fixes with scanners +- Some fixes with connect(). Knowing my luck this will fuck up to hell +- Fixed another memory leak with the scanners +- Fixed some helpop typos reported by BiGi (#0000144) +- Fixed a typo in /stats ? where T/t were reversed, reported by Zer0 +- Fixed a typo displaying a message to edit config.h after compiling reported by dimplesx + (#0000133) +- Fixed a bug where except ban didn't work (reported by Hercules) +- Fixed a scanner memory leak, and made some changes to make the HTTP scanner work +- Fixed a bug in the socks scanner causing it to fail +- Removed some typecasts from free calls, *hopefully* it will fix some problems +- Fixed a bug with \r\n being mistakenly parsed wrong. Thanks to John_z +- Fixed a config parser bug that would cause a crash under certain conditions. Reported by + roskecr (#0000173) +- Rewrote check_pings and the whole way banning people are handled. Do loop.do_bancheck = 1 + to provoke a bans check. This possibly fixes #00001702, #0000137 and other + funny bugs. +- Fixed a number of bugs in the upper patch. +- Fixed an OpenBSD bug reported by RaYmAn, k0adh, and numerous others (#0000104) +- Credits changes +- Fixed problem in dopm (short and char should NEVER be passed to va_arg) +- Fixed HCN so it uses IP instead of sockhost. +- Changed version to beta10 and updated documentation +- Removed obsolete network files +- Added some new network files (hopefully I'll be able to get all the submissions added soon) diff --git a/Makefile.in b/Makefile.in index f3c19240e..a22d90d6c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -153,8 +153,8 @@ build: done @echo ' __________________________________________________ ' @echo '| Compile is now complete. |' - @echo '| You might want to see include/config.h to adjust |' - @echo '| some settings |' + @echo '| You should now read the documentation and learn |' + @echo '| how to configure your IRCd. |' @echo '| |' @echo '| If you really like UnrealIRCd, and would like to |' @echo '| make a donation, please read the Donation file in|' diff --git a/autoconf/configure.in b/autoconf/configure.in index e004531e7..49f5a9e90 100644 --- a/autoconf/configure.in +++ b/autoconf/configure.in @@ -99,10 +99,10 @@ ac_cv_underscore=no else ac_cv_underscore=yes fi +]) if test "$ac_cv_underscore" = "yes"; then AC_DEFINE(UNDERSCORE) fi -]) MODULEFLAGS=$ac_cv_pic AC_DEFINE(DYNAMIC_LINKING) @@ -234,6 +234,12 @@ dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL AC_FUNC_SETPGRP AC_FUNC_SETVBUF_REVERSED +AC_CHECK_FUNCS(snprintf,AC_DEFINE(HAVE_SNPRINTF)) +AC_CHECK_FUNCS(vsnprintf,AC_DEFINE(HAVE_VSNPRINTF)) +AC_CHECK_FUNCS(strlcpy, AC_DEFINE(HAVE_STRLCPY)) +AC_CHECK_FUNCS(strlcat, AC_DEFINE(HAVE_STRLCAT)) +AC_CHECK_FUNCS(strlncat, AC_DEFINE(HAVE_STRLNCAT)) + AC_CACHE_CHECK(if we can set the core size to unlimited, ac_cv_force_core,[ AC_TRY_RUN([ #include diff --git a/configure b/configure index ff4a8ad59..93b19c256 100755 --- a/configure +++ b/configure @@ -2814,8 +2814,299 @@ EOF fi +for ac_func in snprintf +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2821: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_SNPRINTF 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_func in vsnprintf +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2879: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_VSNPRINTF 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_func in strlcpy +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2937: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_STRLCPY 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_func in strlcat +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2995: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3023: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_STRLCAT 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_func in strlncat +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:3053: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_STRLNCAT 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + echo $ac_n "checking if we can set the core size to unlimited""... $ac_c" 1>&6 -echo "configure:2819: checking if we can set the core size to unlimited" >&5 +echo "configure:3110: checking if we can set the core size to unlimited" >&5 if eval "test \"`echo '$''{'ac_cv_force_core'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2824,7 +3115,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -2839,7 +3130,7 @@ exit(0); } EOF -if { (eval echo configure:2843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_force_core=yes else @@ -2862,12 +3153,12 @@ EOF fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:2866: checking for vprintf" >&5 +echo "configure:3157: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -2914,12 +3205,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:2918: checking for _doprnt" >&5 +echo "configure:3209: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -2969,12 +3260,12 @@ fi for ac_func in gettimeofday do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2973: checking for $ac_func" >&5 +echo "configure:3264: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3024,12 +3315,12 @@ else for ac_func in lrand48 do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3028: checking for $ac_func" >&5 +echo "configure:3319: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3347: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3085,12 +3376,12 @@ done for ac_func in getrusage do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3089: checking for $ac_func" >&5 +echo "configure:3380: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3408: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3140,12 +3431,12 @@ else for ac_func in times do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3144: checking for $ac_func" >&5 +echo "configure:3435: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3201,12 +3492,12 @@ done for ac_func in setproctitle do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3205: checking for $ac_func" >&5 +echo "configure:3496: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3254,7 +3545,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for setproctitle in -lutil""... $ac_c" 1>&6 -echo "configure:3258: checking for setproctitle in -lutil" >&5 +echo "configure:3549: checking for setproctitle in -lutil" >&5 ac_lib_var=`echo util'_'setproctitle | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3262,7 +3553,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lutil $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3296,7 +3587,7 @@ else echo "$ac_t""no" 1>&6 cat > conftest.$ac_ext < EOF @@ -3313,12 +3604,12 @@ else for ac_func in pstat do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3317: checking for $ac_func" >&5 +echo "configure:3608: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3380,7 +3671,7 @@ fi done echo $ac_n "checking what type of signals you have""... $ac_c" 1>&6 -echo "configure:3384: checking what type of signals you have" >&5 +echo "configure:3675: checking what type of signals you have" >&5 if eval "test \"`echo '$''{'ac_cv_sigtype'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3389,7 +3680,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -3398,7 +3689,7 @@ sigaction(SIGTERM, (struct sigaction *)0L, (struct sigaction *)0L); } EOF -if { (eval echo configure:3402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sigtype=POSIX else @@ -3410,7 +3701,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -3431,7 +3722,7 @@ exit(0); } EOF -if { (eval echo configure:3435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sigtype=BSD else @@ -3470,12 +3761,12 @@ fi for ac_func in strtoken do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3474: checking for $ac_func" >&5 +echo "configure:3765: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3529,12 +3820,12 @@ done for ac_func in strtok do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3533: checking for $ac_func" >&5 +echo "configure:3824: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3588,12 +3879,12 @@ done for ac_func in strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3592: checking for $ac_func" >&5 +echo "configure:3883: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3647,12 +3938,12 @@ done for ac_func in index do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3651: checking for $ac_func" >&5 +echo "configure:3942: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3706,297 +3997,6 @@ done for ac_func in strtoul do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3710: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -STRTOUL="strtoul.o" -fi -done - -for ac_func in bcopy -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3766: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -cat >> confdefs.h <<\EOF -#define NEED_BCOPY 1 -EOF - -fi -done - -for ac_func in bcmp -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3825: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -cat >> confdefs.h <<\EOF -#define NEED_BCMP 1 -EOF - -fi -done - -for ac_func in bzero -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3884: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3912: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -cat >> confdefs.h <<\EOF -#define NEED_BZERO 1 -EOF - -fi -done - -for ac_func in strcasecmp -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3943: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -$ac_func(); -#endif - -; return 0; } -EOF -if { (eval echo configure:3971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <> confdefs.h <<\EOF -#define GOT_STRCASECMP 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi -done - -for ac_func in inet_addr -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:4001: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4046,22 +4046,19 @@ EOF else echo "$ac_t""no" 1>&6 -cat >> confdefs.h <<\EOF -#define NEED_INET_ADDR 1 -EOF - +STRTOUL="strtoul.o" fi done -for ac_func in inet_ntoa +for ac_func in bcopy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4060: checking for $ac_func" >&5 +echo "configure:4057: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +cat >> confdefs.h <<\EOF +#define NEED_BCOPY 1 +EOF + +fi +done + +for ac_func in bcmp +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:4116: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +cat >> confdefs.h <<\EOF +#define NEED_BCMP 1 +EOF + +fi +done + +for ac_func in bzero +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:4175: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +cat >> confdefs.h <<\EOF +#define NEED_BZERO 1 +EOF + +fi +done + +for ac_func in strcasecmp +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:4234: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define GOT_STRCASECMP 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_func in inet_addr +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:4292: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +cat >> confdefs.h <<\EOF +#define NEED_INET_ADDR 1 +EOF + +fi +done + +for ac_func in inet_ntoa +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:4351: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4115,12 +4406,12 @@ done for ac_func in inet_netof do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4119: checking for $ac_func" >&5 +echo "configure:4410: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4174,12 +4465,12 @@ done for ac_func in syslog do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4178: checking for $ac_func" >&5 +echo "configure:4469: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4232,12 +4523,12 @@ done for ac_func in vsyslog do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4236: checking for $ac_func" >&5 +echo "configure:4527: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4448,7 +4739,7 @@ cat >> confdefs.h <<\EOF EOF echo $ac_n "checking what order we should supply the SSL libraries in""... $ac_c" 1>&6 -echo "configure:4452: checking what order we should supply the SSL libraries in" >&5 +echo "configure:4743: checking what order we should supply the SSL libraries in" >&5 if eval "test \"`echo '$''{'ac_cv_ssl_libs'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4456,7 +4747,7 @@ else save_libs="$LIBS" LIBS="$LIBS -lssl -lcrypto -lssl" cat > conftest.$ac_ext < int main() { @@ -4465,7 +4756,7 @@ SSL_write(NULL, NULL, NULL); ; return 0; } EOF -if { (eval echo configure:4469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4760: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_ssl_libs="-lssl -lcrypto -lssl" LIBS="$save_libs" else @@ -4491,12 +4782,12 @@ if test "${enable_dynamic_linking+set}" = set; then enableval="$enable_dynamic_linking" echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:4495: checking for dlopen" >&5 +echo "configure:4786: checking for dlopen" >&5 if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_dlopen=yes" else @@ -4537,7 +4828,7 @@ if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4541: checking for dlopen in -ldl" >&5 +echo "configure:4832: checking for dlopen in -ldl" >&5 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4545,7 +4836,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4585,20 +4876,20 @@ fi hold_cflags=$CFLAGS CFLAGS="$CFLAGS -export-dynamic" echo $ac_n "checking if we need the -export-dynamic flag""... $ac_c" 1>&6 -echo "configure:4589: checking if we need the -export-dynamic flag" >&5 +echo "configure:4880: checking if we need the -export-dynamic flag" >&5 if eval "test \"`echo '$''{'ac_cv_export_dynamic'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_export_dynamic=yes else @@ -4616,7 +4907,7 @@ CFLAGS=$hold_cflags fi echo $ac_n "checking for compiler option to produce PIC""... $ac_c" 1>&6 -echo "configure:4620: checking for compiler option to produce PIC" >&5 +echo "configure:4911: checking for compiler option to produce PIC" >&5 if eval "test \"`echo '$''{'ac_cv_pic'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4635,7 +4926,7 @@ fi echo "$ac_t""$ac_cv_pic" 1>&6 echo $ac_n "checking if your system prepends an underscore on symbols""... $ac_c" 1>&6 -echo "configure:4639: checking if your system prepends an underscore on symbols" >&5 +echo "configure:4930: checking if your system prepends an underscore on symbols" >&5 if eval "test \"`echo '$''{'ac_cv_underscore'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4651,6 +4942,10 @@ ac_cv_underscore=no else ac_cv_underscore=yes fi + +fi + +echo "$ac_t""$ac_cv_underscore" 1>&6 if test "$ac_cv_underscore" = "yes"; then cat >> confdefs.h <<\EOF #define UNDERSCORE 1 @@ -4658,10 +4953,6 @@ EOF fi -fi - -echo "$ac_t""$ac_cv_underscore" 1>&6 - MODULEFLAGS=$ac_cv_pic cat >> confdefs.h <<\EOF #define DYNAMIC_LINKING 1 @@ -4680,7 +4971,7 @@ if test "${enable_inet6+set}" = set; then enableval="$enable_inet6" echo $ac_n "checking if your system has IPv6 support""... $ac_c" 1>&6 -echo "configure:4684: checking if your system has IPv6 support" >&5 +echo "configure:4975: checking if your system has IPv6 support" >&5 if eval "test \"`echo '$''{'ac_cv_ip6'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4689,7 +4980,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -4701,7 +4992,7 @@ exit(0); } EOF -if { (eval echo configure:4705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4996: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_ip6=yes else @@ -4763,7 +5054,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:4767: checking host system type" >&5 +echo "configure:5058: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -4789,17 +5080,17 @@ acx_pthread_ok=no # If it isn't, don't bother looking for the threads libraries. ac_safe=`echo "pthread.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for pthread.h""... $ac_c" 1>&6 -echo "configure:4793: checking for pthread.h" >&5 +echo "configure:5084: checking for pthread.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4803: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5094: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4868,7 +5159,7 @@ esac result=none if test "$acx_pthread_ok" = "no"; then echo $ac_n "checking what flags pthreads needs""... $ac_c" 1>&6 -echo "configure:4872: checking what flags pthreads needs" >&5 +echo "configure:5163: checking what flags pthreads needs" >&5 if eval "test \"`echo '$''{'ac_cv_pthreadflag'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4906,7 +5197,7 @@ for flag in $acx_pthread_flags; do # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat > conftest.$ac_ext < int main() { @@ -4915,7 +5206,7 @@ pthread_t th; pthread_join(th, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ; return 0; } EOF -if { (eval echo configure:4919: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* acx_pthread_ok=yes else @@ -4961,20 +5252,20 @@ esac # Detect AIX lossage: threads are created detached by default # and the JOINABLE attribute has a nonstandard name (UNDETACHED). echo $ac_n "checking for joinable pthread attribute""... $ac_c" 1>&6 -echo "configure:4965: checking for joinable pthread attribute" >&5 +echo "configure:5256: checking for joinable pthread attribute" >&5 if eval "test \"`echo '$''{'ac_cv_pthreadjoin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { int attr=PTHREAD_CREATE_JOINABLE; ; return 0; } EOF -if { (eval echo configure:4978: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_pthreadjoin=PTHREAD_CREATE_JOINABLE else @@ -4986,14 +5277,14 @@ fi rm -f conftest* if test "$ac_cv_pthreadjoin" = "unknown"; then cat > conftest.$ac_ext < int main() { int attr=PTHREAD_CREATE_UNDETACHED; ; return 0; } EOF -if { (eval echo configure:4997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5288: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_pthreadjoin=PTHREAD_CREATE_UNDETACHED else @@ -5019,7 +5310,7 @@ EOF fi echo $ac_n "checking if more special flags are required for pthreads""... $ac_c" 1>&6 -echo "configure:5023: checking if more special flags are required for pthreads" >&5 +echo "configure:5314: checking if more special flags are required for pthreads" >&5 if eval "test \"`echo '$''{'ac_cv_pthreadspecial'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5044,7 +5335,7 @@ echo "$ac_t""$ac_cv_pthreadspecial" 1>&6 # Extract the first word of "cc_r", so it can be a program name with args. set dummy cc_r; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5048: checking for $ac_word" >&5 +echo "configure:5339: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_PTHREAD_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5076,7 +5367,7 @@ else fi if test "x$ac_cv_pthreadflag"!=x; then echo $ac_n "checking if pthreads uses one thread per process""... $ac_c" 1>&6 -echo "configure:5080: checking if pthreads uses one thread per process" >&5 +echo "configure:5371: checking if pthreads uses one thread per process" >&5 if eval "test \"`echo '$''{'ac_cv_thread_multi'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5089,7 +5380,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -5123,7 +5414,7 @@ int main() { } EOF -if { (eval echo configure:5127: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_thread_multi=no else @@ -5199,12 +5490,12 @@ CC="$PTHREAD_CC" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" IRCDLIBS="$IRCDLIBS $PTHREAD_LIBS" echo $ac_n "checking if FD_SETSIZE is large enough to allow $ac_fd file descriptors""... $ac_c" 1>&6 -echo "configure:5203: checking if FD_SETSIZE is large enough to allow $ac_fd file descriptors" >&5 +echo "configure:5494: checking if FD_SETSIZE is large enough to allow $ac_fd file descriptors" >&5 if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -5216,7 +5507,7 @@ exit(1); } EOF -if { (eval echo configure:5220: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5511: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""yes" 1>&6 else diff --git a/doc/conf.doc b/doc/conf.doc index 814fa32ea..df782e4d7 100644 --- a/doc/conf.doc +++ b/doc/conf.doc @@ -973,6 +973,9 @@ If set to no, the user must set +x manually to receive the oper host. set::scan::endpoint ; Specifies the IP and port that the server will tell an incomming open proxy to connect to. +This must be a valid IP and port, in addition the port on the specified IP must be open and +able to accept connections. Therefore it is a good idea to specify the IP of your server +and a port you know is open. set::scan::bantime ; A time value that defines the length of time that a user caught by the scanner will be diff --git a/doc/example.conf b/doc/example.conf index f93c8ecdb..8e485a17c 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -576,7 +576,7 @@ except ban { }; /* - * NEW: except socks {} + * NEW: except scan {} * OLD: e:Line * Makes it so scan.so doesn't scan you. * @@ -701,7 +701,7 @@ set { show-connect-info; }; - socks { + scan { ban-message "Insecure SOCKS server"; quit-message "Insecure SOCKS server"; ban-time "4d"; diff --git a/help.conf b/help.conf index 02f8ca5bf..ca8301720 100644 --- a/help.conf +++ b/help.conf @@ -61,7 +61,7 @@ help Svscmds { " /MSG OPERSERV RAW :services "; " Use /HELPOP to get info about that command"; " -"; - " ----------oOo-----------"; + " -----------oOo-----------"; " SVSNICK SVSMODE SVSKILL"; " SVSNOOP SVSJOIN SVSPART"; " SVSO SWHOIS SQLINE"; @@ -1059,3 +1059,12 @@ help Svsfline { " :server SVSFLINE - file (Deletes the filename)"; " :server SVSFLINE * (Wipes the DCCDENY list)"; }; + +help Svsmotd { + "Changes the Services Message Of The Day"; + "Must be sent through an U:Lined server."; + "Syntax: SVSMOTD # : (Adds to Services MOTD)"; + " SVSMOTD ! (Deletes the MOTD)"; + " SVSMOTD ! : (Deletes and Adds text)"; + "Example: SVSMOTD # :Services MOTD"; +}; diff --git a/html/back/background.jpg b/html/back/background.jpg index a599c3a60..2a0e64a66 100644 Binary files a/html/back/background.jpg and b/html/back/background.jpg differ diff --git a/html/back/grad.jpg b/html/back/grad.jpg index bd250055a..3ed1e81e9 100755 Binary files a/html/back/grad.jpg and b/html/back/grad.jpg differ diff --git a/html/icons/conffiles.jpg b/html/icons/conffiles.jpg index f0ba962cf..c761902c3 100644 Binary files a/html/icons/conffiles.jpg and b/html/icons/conffiles.jpg differ diff --git a/html/icons/modules.jpg b/html/icons/modules.jpg index b908e3b6e..c2299c565 100644 Binary files a/html/icons/modules.jpg and b/html/icons/modules.jpg differ diff --git a/html/icons/opers.jpg b/html/icons/opers.jpg index 4a84cc12f..ce1a0b5c0 100644 Binary files a/html/icons/opers.jpg and b/html/icons/opers.jpg differ diff --git a/html/icons/settings.jpg b/html/icons/settings.jpg index f04d9c1d4..ceea8bdba 100644 Binary files a/html/icons/settings.jpg and b/html/icons/settings.jpg differ diff --git a/html/icons/stats.jpg b/html/icons/stats.jpg index bd7f4e691..331a51024 100644 Binary files a/html/icons/stats.jpg and b/html/icons/stats.jpg differ diff --git a/html/icons/users.jpg b/html/icons/users.jpg index 0019333fc..5b597830d 100644 Binary files a/html/icons/users.jpg and b/html/icons/users.jpg differ diff --git a/include/common.h b/include/common.h index 9c7c60d2d..7bb8312e7 100644 --- a/include/common.h +++ b/include/common.h @@ -130,7 +130,7 @@ extern char *strtoken(char **, char *, char *); #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif -#define DupString(x,y) do{x=MyMalloc(strlen(y)+1);(void)strcpy(x,y);}while(0) +#define DupString(x,y) do{int l=strlen(y);x=MyMalloc(l+1);(void)memcpy(x,y, l+1);}while(0) extern u_char tolowertab[], touppertab[]; diff --git a/include/config.h b/include/config.h index 58d3e97e5..a579288b1 100644 --- a/include/config.h +++ b/include/config.h @@ -594,14 +594,14 @@ #ifdef BSD_RELIABLE_SIGNALS # if defined(SYSV_UNRELIABLE_SIGNALS) || defined(POSIX_SIGNALS) error You stuffed up config.h signals -#defines use only one. +#define use only one. # endif #define HAVE_RELIABLE_SIGNALS #endif #ifdef SYSV_UNRELIABLE_SIGNALS # ifdef POSIX_SIGNALS error You stuffed up config.h signals -#defines use only one. +#define use only one. # endif #undef HAVE_RELIABLE_SIGNALS #endif diff --git a/include/h.h b/include/h.h index 66f0a35dc..d34b19548 100644 --- a/include/h.h +++ b/include/h.h @@ -45,7 +45,7 @@ extern struct stats *ircstp; extern int bootopt; extern time_t TSoffset; /* Prototype added to force errors -- Barubary */ -extern TS check_pings(TS now, int check_kills); +extern TS check_pings(TS now); extern TS TS2ts(char *s); extern time_t timeofday; /* newconf */ @@ -77,6 +77,7 @@ extern ConfigItem_admin *conf_admin; extern ConfigItem_admin *conf_admin_tail; extern ConfigItem_drpass *conf_drpass; extern ConfigItem_ulines *conf_ulines; +extern ConfigItem_ssl *conf_ssl; extern ConfigItem_tld *conf_tld; extern ConfigItem_oper *conf_oper; extern ConfigItem_listen *conf_listen; @@ -205,6 +206,13 @@ extern char *strerror(int); extern int dgets(int, char *, int); extern char *inetntoa(char *); +#if !defined(HAVE_SNPRINT) || !defined(HAVE_VSNPRINTF) +#ifndef _WIN32 +extern int snprintf (char *str, size_t count, const char *fmt, ...); +extern int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); +#endif +#endif + #ifdef _WIN32 extern int dbufalloc, dbufblocks, debuglevel; #else @@ -411,6 +419,15 @@ extern long UMODE_HIDEOPER; /* 0x20000000 Hide oper mode */ extern long UMODE_SETHOST; /* 0x40000000 used sethost */ extern long UMODE_STRIPBADWORDS; /* 0x80000000 */ +#ifndef HAVE_STRLCPY +size_t strlcpy(char *dst, const char *src, size_t size); +#endif +#ifndef HAVE_STRLCAT +size_t strlcat(char *dst, const char *src, size_t size); +#endif +#ifndef HAVE_STRLNCAT +size_t strlncat(char *dst, const char *src, size_t size, size_t n); +#endif extern int dopacket(aClient *, char *, int); diff --git a/include/proto.h b/include/proto.h index f3eb176b3..d67f74828 100644 --- a/include/proto.h +++ b/include/proto.h @@ -56,7 +56,6 @@ char *my_itoa(int i); /* s_kline.c */ int find_tkline_match(aClient *cptr, int xx); extern EVENT(tkl_check_expire); -int tkl_sweep(void); /* s_serv.c */ void load_tunefile(void); diff --git a/include/struct.h b/include/struct.h index 7c17479c4..ebb0236da 100644 --- a/include/struct.h +++ b/include/struct.h @@ -82,6 +82,7 @@ typedef struct _configitem_listen ConfigItem_listen; typedef struct _configitem_allow ConfigItem_allow; typedef struct _configitem_allow_channel ConfigItem_allow_channel; typedef struct _configitem_vhost ConfigItem_vhost; +typedef struct _configitem_ssl ConfigItem_ssl; typedef struct _configitem_except ConfigItem_except; typedef struct _configitem_link ConfigItem_link; typedef struct _configitem_ban ConfigItem_ban; @@ -344,7 +345,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define SendWallops(x) (!IsMe(x) && ((x)->umodes & UMODE_WALLOP)) #define SendServNotice(x) (((x)->user) && ((x)->user->snomask & SNO_SNOTICE)) #define IsListening(x) ((x)->flags & FLAGS_LISTEN) -#define DoAccess(x) ((x)->flags & FLAGS_CHKACCESS) +// #define DoAccess(x) ((x)->flags & FLAGS_CHKACCESS) #define IsLocal(x) ((x)->flags & FLAGS_LOCAL) #define IsDead(x) ((x)->flags & FLAGS_DEADSOCKET) #define GotProtoctl(x) ((x)->flags & FLAGS_PROTOCTL) @@ -389,7 +390,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define SetWallops(x) ((x)->umodes |= UMODE_WALLOP) #define SetDNS(x) ((x)->flags |= FLAGS_DOINGDNS) #define DoingDNS(x) ((x)->flags & FLAGS_DOINGDNS) -#define SetAccess(x) ((x)->flags |= FLAGS_CHKACCESS) +#define SetAccess(x) ((x)->flags |= FLAGS_CHKACCESS); Debug((DEBUG_DEBUG, "SetAccess(%s)", (x)->name)) #define SetBlocked(x) ((x)->flags |= FLAGS_BLOCKED) #define DoingAuth(x) ((x)->flags & FLAGS_AUTH) #define NoNewLine(x) ((x)->flags & FLAGS_NONL) @@ -588,8 +589,8 @@ struct MotdItem { struct aloopStruct { unsigned do_garbage_collect : 1; - unsigned do_tkl_sweep : 1; unsigned ircd_booted : 1; + unsigned do_bancheck : 1; }; typedef struct Whowas { @@ -935,6 +936,14 @@ struct _configitem_listen { char *ip; int port; long options, clients; + ConfigItem_ssl *ssl; +}; + +struct _configitem_ssl { + char *cert; + char *key; + char *ca; + char *cipher; }; struct _configitem_vhost { diff --git a/include/threads.h b/include/threads.h index 19bc384d4..8d929081b 100644 --- a/include/threads.h +++ b/include/threads.h @@ -33,10 +33,9 @@ #endif #if !defined(_WIN32) || defined(USE_PTHREADS) #include -typedef pthread_attr_t THREAD_ATTR; typedef pthread_t THREAD; typedef pthread_mutex_t MUTEX; -#define IRCCreateThread(thread, attr, start, arg) TDebug(CreateThread); pthread_attr_init(&attr); pthread_create(&thread, &attr, (void*)start, arg) +#define IRCCreateThread(thread, start, arg) TDebug(CreateThread); pthread_create(&thread, NULL, (void*)start, arg) #define IRCMutexLock(mutex) TDebug(MutexLock); pthread_mutex_lock(&mutex) #define IRCMutexTryLock(mutex) TDebug(MutexTryLock); pthread_mutex_trylock(&mutex); #define IRCMutexUnlock(mutex) TDebug(MutexUnlcok); pthread_mutex_unlock(&mutex) @@ -44,14 +43,14 @@ typedef pthread_mutex_t MUTEX; #define IRCMutexDestroy(mutex) TDebug(MutexDestroy); pthread_mutex_destroy(&mutex) #define IRCJoinThread(thread,return) TDebug(JoinThread); pthread_join(thread, return) #define IRCExitThread(value) TDebug(ExitThread); pthread_exit(value) +#define IRCDetachThread(value) TDebug(DetachThread); pthread_detach(value); #define IRCTerminateThread(thread, value) pthread_cancel(&thread) #define IRCThreadSelf() pthread_self() #define IRCThreadEqual(thread1, thread2) pthread_equal(thread1,thread2) #else -typedef short THREAD_ATTR; /* Not needed but makes porting easier */ typedef unsigned long THREAD; typedef HANDLE MUTEX; -#define IRCCreateThread(thread, attr, start, arg) thread = _beginthread((void *)start, 0, arg) +#define IRCCreateThread(thread, start, arg) thread = _beginthread((void *)start, 0, arg) #define IRCMutexLock(mutex) WaitForSingleObject(mutex, INFINITE) #define IRCMutexTryLock(mutex) WaitForSingleObject(mutex, 0) #define IRCMutexUnlock(mutex) ReleaseMutex(mutex) @@ -62,6 +61,7 @@ typedef HANDLE MUTEX; #define IRCTerminateThread(thread, value) TerminateThread((HANDLE)thread, value) #define IRCThreadSelf() GetCurrentThread() #define IRCThreadEqual(thread1, thread2) thread1 == thread2 ? 1 : 0 +#define IRCDetachThread(value) ; #endif #endif diff --git a/include/version.h b/include/version.h index 31334dda3..e38b9898e 100644 --- a/include/version.h +++ b/include/version.h @@ -31,7 +31,7 @@ #define PATCH1 "3" #define PATCH2 ".2" #define PATCH3 "-Selene" -#define PATCH4 "[beta9]" +#define PATCH4 "[beta10]" #define PATCH5 "" #define PATCH6 "" #define PATCH7 "" diff --git a/networks/awesomechristians.network b/networks/awesomechristians.network new file mode 100644 index 000000000..a62ab119b --- /dev/null +++ b/networks/awesomechristians.network @@ -0,0 +1,28 @@ +/* + * AwesomeChristians Chat Network (irc.awesomechristians.com) Network Configuration File + * -------------------------------------------------- + * Added-at: 31 December 2001 15:25 + * Author: ChildLikeFaith + * Email: childlikefaith@awesomechristians.com + * ----------------------------------------- + */ + +set { + network-name "AwesomeChristians Chat Network"; + default-server "irc.awesomechristians.com"; + services-server "services.awesomechristians.com"; + stats-server "services.awesomechristians.com"; + help-channel "#operhelp"; + hiddenhost-prefix "awesome"; + prefix-quit "Quit:"; + hosts { + local "ircop.awesomechristians.net"; + global "ircop.awesomechristians.net"; + coadmin "co.admin.awesomechristians.net"; + admin "admin.awesomechristians.net"; + servicesadmin "services.admin.awesomechristians.net"; + netadmin "network.admin.awesomechristians.net"; + host-on-oper-up "on"; + }; +}; + diff --git a/networks/ctcp.network b/networks/ctcp.network new file mode 100644 index 000000000..b5b2fb7e8 --- /dev/null +++ b/networks/ctcp.network @@ -0,0 +1,26 @@ +/* + * CTCP Networks (irc.ctcp.net) Network Configuration File + * + * Added-at: 12 February 2002 19:54 + * Author: Mark + * Email: mark@ctcp.net + */ + +set { + network-name "CTCP Networks"; + default-server "irc.ctcp.net"; + services-server "services.ctcp.net"; + stats-server "stats.ctcp.net"; + help-channel "#opers"; + hiddenhost-prefix "ctcp"; + hosts { + local "locop.ctcp.net"; + global "oper.ctcp.net"; + coadmin "coadmin.ctcp.net"; + admin "admin.ctcp.net"; + servicesadmin "csop.ctcp.net"; + netadmin "netadmin.ctcp.net"; + host-on-oper-up yes; + }; +}; + diff --git a/networks/darkkaos.network b/networks/darkkaos.network new file mode 100644 index 000000000..5c1c01e4c --- /dev/null +++ b/networks/darkkaos.network @@ -0,0 +1,26 @@ +/* + * Dark Kaos Network (irc.darkkaos.net) Network Configuration File + * + * Added-at: 04 February 2002 03:15 + * Author: ka0t1c_m4n + * Email: drk_kaos@yahoo.com + */ + +set { + network-name "Dark Kaos Network"; + default-server "irc.darkkaos.net"; + services-server "services.darkkaos.net"; + stats-server "stats.darkkaos.net"; + help-channel "#help"; + hiddenhost-prefix "hide"; + hosts { + local "localop.darkkaos.net"; + global "would.u.like.to.be.me.com"; + coadmin "ircop.darkkaos.net"; + admin "i.hate.terr.oists.net"; + servicesadmin "Csop.darkkaos.net"; + netadmin "netadmin.darkkaos.net"; + host-on-oper-up yes; + }; +}; + diff --git a/networks/discussioni.network b/networks/discussioni.network new file mode 100644 index 000000000..d07d37ef7 --- /dev/null +++ b/networks/discussioni.network @@ -0,0 +1,26 @@ +/* + * Discussioni.Org (IRC.Discussioni.Org) Network Configuration File + * + * Added-at: 17 January 2002 22:39 + * Author: Jollino + * Email: jollino@discussioni.org + */ + +set { + network-name "Discussioni.Org"; + default-server "IRC.Discussioni.Org"; + services-server "Services.Discussioni.Org"; + stats-server "Stats.Discussioni.Org"; + help-channel "#help"; + hiddenhost-prefix "DISCUSSIONI"; + hosts { + local "LocOp.Discussioni.Org"; + global "Oper.Discussioni.Org"; + coadmin "Co-Admin.Discussioni.Org"; + admin "Admin.Discussioni.Org"; + servicesadmin "ServOper.Discussioni.Org"; + netadmin "NetAdmin.Discussioni.Org"; + host-on-oper-up yes; + }; +}; + diff --git a/networks/icechat.network b/networks/icechat.network new file mode 100644 index 000000000..105b04eb2 --- /dev/null +++ b/networks/icechat.network @@ -0,0 +1,26 @@ +/* + * IceChat (irc.icechat.net) Network Configuration File + * + * Added-at: 19 February 2002 16:55 + * Author: Rosco + * Email: pssystem@home.com + */ + +set { + network-name "IceChat"; + default-server "irc.icechat.net"; + services-server "services.icechat.net"; + stats-server "stats.icechat.net"; + help-channel "#help"; + hiddenhost-prefix "00"; + hosts { + local "locop.icechat.net"; + global "oper.icechat.net"; + coadmin "coadmin.icechat.net"; + admin "admin.icechat.net"; + servicesadmin "csop.icechat.net"; + netadmin "netadmin.icechat.net"; + host-on-oper-up yes; + }; +}; + diff --git a/networks/ircsystems.network b/networks/ircsystems.network new file mode 100644 index 000000000..6e082b612 --- /dev/null +++ b/networks/ircsystems.network @@ -0,0 +1,29 @@ +/* + * ROXnet (irc.rox.za.net) Network Configuration File + * -------------------------------------------------- + * Added-at: 14 July 1999 00:00 GMT + * Author: Stskeeps (Carsten Munk) + * E-Mail: stskeeps@roxnet.org + * $Id$ + * ----------------------------------------- + */ + +set { + network-name "IRCsystems"; + default-server "irc.ircsystems.net"; + services-server "services.ircsystems.net"; + stats-server "stats.ircsystems.net"; + help-channel "#IRCsystems"; + hiddenhost-prefix "rox"; + prefix-quit "Quit:"; + hosts { + local "locop.ircsystems.net"; + global "ircop.ircsystems.net"; + coadmin "coadmin.ircsystems.net"; + admin "admin.ircsystems.net"; + servicesadmin "csops.ircsystems.net"; + techadmin "techadmin.ircsystems.net"; + netadmin "netadmin.ircsystems.net"; + host-on-oper-up "off"; + }; +}; diff --git a/networks/l33t-irc.network b/networks/l33t-irc.network new file mode 100644 index 000000000..b2005f890 --- /dev/null +++ b/networks/l33t-irc.network @@ -0,0 +1,26 @@ +/* + * l33t-irc.com (irc.l33t-irc.com) Network Configuration File + * + * Added-at: 04 January 2002 15:46 + * Author: [LW]FlOwBiE + * Email: flowbie@l33t-irc.com + */ + +set { + network-name "l33t-irc.com"; + default-server "irc.l33t-irc.com"; + services-server "services.l33t-irc.com"; + stats-server "stats.l33t-irc.com"; + help-channel "#l33t-irc.com"; + hiddenhost-prefix "l33t-irc.com"; + hosts { + local "local.l33t-irc.com"; + global "l33t-irc"; + coadmin "coadmin.l33t-irc.com"; + admin "admin.l33t-irc.com"; + servicesadmin "servicesadmin.l33t-irc.com"; + netadmin "netadmin.l33t-irc.com"; + host-on-oper no; + }; +}; + diff --git a/networks/networks.ndx b/networks/networks.ndx index 9b783f8db..5978389f5 100644 --- a/networks/networks.ndx +++ b/networks/networks.ndx @@ -6,57 +6,33 @@ * of these networks. */ -networks/action-irc.network ......: Action-IRC (http://www.action-irc.net) +networks/awesomechristians.network: Awesome Christians Chat Network (http://www.awesomechristians.com) networks/axenet.network ..........: AXEnet (http://www.axenet.org) -networks/bitchx.network ..........: BitchX (http://www.bitchx.cl) -networks/blind-irc.network .......: Blind-Irc (http://www.blind-irc.com) networks/bunker7.network .........: Bunker7 (http://www.bunker7.net) networks/burnnet.network .........: BuRnNET (http://www.burncycl.net) networks/cabonet.network .........: CaboNet (http://www.cabonet.org) -networks/cc2.network .............: CC2 (http://www.cc2.org) networks/chatcrap.network ........: ChatCrap (http://www.chatcrap.com) networks/chatuniverse.network ....: ChatUniverse (http://www.chatuniverse.net) -networks/coolchat.network ........: Coolchat (http://www.coolchat.net) -networks/cynicnet.network ........: CynicNet (http://www.cynicnet.org) -networks/dark-core.network .......: Dark Core Networks -networks/darkfyre.network ........: Darkfyre (http://www.darkfyre.net) -networks/darkwar.network .........: Darkwar (http://www.darkwar.net) +networks/ctcp.network ............: CTCP Networks (http://www.ctcp.net) +networks/darkkaos.network ........: Dark Kaos Network (http://www.darkkaos.net) networks/digitalirc.network ......: DigitalIRC (http://www.digitalirc.net) +networks/discussioni.network .....: Discussioni.org (http://www.discussioni.org) networks/dragonwings.network .....: DragonWings (http://www.dragonwings.org) -networks/fireirc.network .........: FireIRC (http://www.fireirc.net) -networks/flort.network ...........: Flort -networks/friendlyirc.network .....: FriendlyIRC (http://www.friendlyirc.net) networks/gamescafe.network .......: GamesCafe (http://www.gamerscafe.net) -networks/geridnet.network ........: Gerid.Net (http://www.gerid.net) networks/german-elite.network ....: German-Elite (http://www.german-elite.net) networks/german-global-irc.network: German Global IRC (http://www.global-irc.de) networks/globalchat.network ......: GlobalChat (http://www.globalchat.ca) networks/global-irc.network ......: Global-IRC (http://www.global-irc.net) -networks/globo.network ...........: Globo +networks/icechat.network .........: IceChat (http://www.icechat.net) networks/infinity.network ........: Infinity-IRC.org (http://www.infinity-irc.org) -networks/irclatino.network .......: IRCLatino (http://www.irclatino.org) -networks/irc4ever.network ........: IRC4ever (http://www.irc4ever.net) networks/isno.network ............: Isno (http://www.isno.net) -networks/israelnet.network .......: IsraelNet (http://www.israel.net) +networks/l33t-irc.network ........: L33T-IRC (http://www.l33t-irc.com) networks/lcirc.network ...........: LCIrc (http://www.lcirc.net) -networks/lostchat.network ........: Lostchat (http://www.lostchat.net) -networks/maxatnet.network ........: MaxatNet -networks/phatnet.network .........: PhatNet (http://www.phat-net.de) +networks/outsiderz.network .......: Outsiderz (http://www.outsiderz.com) networks/phazenet.network ........: PhazeNet (http://www.phazenet.com) -networks/pheernet.network ........: PheerNet (http://www.pheernet.org) -networks/roxnet.network ..........: ROXnet (http://www.roxnet.org) -networks/shallomchat.network .....: ShallomChat (http://www.shallomchat.org) -networks/solargalaxy.network .....: SolarGalaxy (http://www.solargalaxy.net) -netwrosk/spamnet.network .........: SpamNet (http://www.spamnet.org) -networks/spin.network ............: SpiN (http://www.spinempire.com) -networks/starequinox.network .....: StarEquinox (http://www.starequinox.net) networks/stormdancing.network ....: StormDancing (http://www.stormdancing.net) networks/thainet.network .........: Thai IRC Network -networks/tspre.network ...........: TSpre (http://www.tspre.org) -networks/unitedirc.network .......: UnitedIRC (http://www.unitedirc.com) networks/unitedirc-org.network ...: Unitedirc (http://www.unitedirc.org) -networks/united-irc.network ......: united-irc -networks/uzaynet.network .........: UzayNet (http://www.uzaynet.nu) networks/wazzza.network ..........: wazZza (http://www.wazzza.org) networks/x-irc.network ...........: x-irc (http://www.x-irc.net) networks/zirc.network ............: ZiRC (http://www.zirc.org) diff --git a/networks/outsiderz.network b/networks/outsiderz.network new file mode 100644 index 000000000..78bc71a85 --- /dev/null +++ b/networks/outsiderz.network @@ -0,0 +1,26 @@ +* + * Outsiderz.com (irc.Outsiderz.com) Network Configuration File + * + * Added-at: 29 January 2002 07:35 + * Author: DrDeath + * Email: DrDeath@hotmail.com + */ + +set { + network-name "Outsiderz.com"; + default-server "irc.Outsiderz.com"; + services-server "services.outsiderz.com"; + stats-server "stats.outsiderz.com"; + help-channel "#Outsiderz"; + hiddenhost-prefix "Outsiderz"; + hosts { + local "LocOP.Outsiderz.com"; + global "IrcOP.Outsiderz.com"; + coadmin "CoAdmin.Outsiderz.com"; + admin "Admin.Outsiderz.com"; + servicesadmin "CsOP.Outsiderz.com"; + netadmin "NetAdmin.Outsiderz.com"; + host-on-oper-up yes; + }; +}; + diff --git a/src/badwords.c b/src/badwords.c index 47d696db8..4e7b8d6f0 100644 --- a/src/badwords.c +++ b/src/badwords.c @@ -50,12 +50,15 @@ char *stripbadwords_channel(char *str) char *ptr; int errorcode, matchlen, stringlen; ConfigItem_badword *this_word; - + size_t n; if (!conf_badword_channel) return str; - strncpy(cleanstr, str, sizeof(cleanstr) - 1); /* Let's work on a backup */ - memset(&pmatch, 0, sizeof(pmatch)); - stringlen = strlen(cleanstr); + + /* + * work on a copy + */ + stringlen = strlcpy(cleanstr, str, sizeof cleanstr); + memset(&pmatch, 0, sizeof pmatch); matchlen = 0; buf[0] = '\0'; @@ -68,23 +71,28 @@ char *stripbadwords_channel(char *str) return cleanstr; } - ptr = cleanstr; /* Set pointer to start of string */ + /* + * Set pointer to start of string + */ + ptr = cleanstr; + while (regexec(&pcomp, ptr, MAX_MATCH, pmatch, 0) != REG_NOMATCH) { if (pmatch[0].rm_so == -1) break; matchlen += pmatch[0].rm_eo - pmatch[0].rm_so; - strncat(buf, ptr, pmatch[0].rm_so); + strlncat(buf, ptr, sizeof buf, pmatch[0].rm_so); if (this_word->replace) - strcat(buf, this_word->replace); + strlcat(buf, this_word->replace, sizeof buf); else - strcat(buf, REPLACEWORD); + strlcat(buf, REPLACEWORD, sizeof buf); ptr += pmatch[0].rm_eo; /* Set pointer after the match pos */ memset(&pmatch, 0, sizeof(pmatch)); } - strcat(buf, ptr); /* All the better to eat you with! */ - strncpy(cleanstr, buf, sizeof(cleanstr)); + /* All the better to eat you with! */ + strlcat(buf, ptr, sizeof buf); + memcpy(cleanstr, buf, sizeof cleanstr); memset(buf, 0, sizeof(buf)); regfree(&pcomp); if (matchlen == stringlen) @@ -101,18 +109,21 @@ char *stripbadwords_message(char *str) static char cleanstr[4096]; char buf[4096]; char *ptr; - ConfigItem_badword *this_word; int errorcode, matchlen, stringlen; - + ConfigItem_badword *this_word; + size_t n; if (!conf_badword_message) return str; - strncpy(cleanstr, str, sizeof(cleanstr) - 1); /* Let's work on a backup */ - memset(&pmatch, 0, sizeof(pmatch)); - stringlen = strlen(cleanstr); + + /* + * work on a copy + */ + stringlen = strlcpy(cleanstr, str, sizeof cleanstr); + memset(&pmatch, 0, sizeof pmatch); matchlen = 0; buf[0] = '\0'; - for (this_word = conf_badword_message; this_word; this_word = (ConfigItem_badword *)this_word->next) + for (this_word = conf_badword_message; this_word; this_word = (ConfigItem_badword *)this_word->next) { if ((errorcode = regcomp(&pcomp, this_word->word, REG_ICASE)) > 0) @@ -121,23 +132,28 @@ char *stripbadwords_message(char *str) return cleanstr; } - ptr = cleanstr; /* Set pointer to start of string */ + /* + * Set pointer to start of string + */ + ptr = cleanstr; + while (regexec(&pcomp, ptr, MAX_MATCH, pmatch, 0) != REG_NOMATCH) { if (pmatch[0].rm_so == -1) break; matchlen += pmatch[0].rm_eo - pmatch[0].rm_so; - strncat(buf, ptr, pmatch[0].rm_so); + strlncat(buf, ptr, sizeof buf, pmatch[0].rm_so); if (this_word->replace) - strcat(buf, this_word->replace); + strlcat(buf, this_word->replace, sizeof buf); else - strcat(buf, REPLACEWORD); + strlcat(buf, REPLACEWORD, sizeof buf); ptr += pmatch[0].rm_eo; /* Set pointer after the match pos */ memset(&pmatch, 0, sizeof(pmatch)); } - strcat(buf, ptr); /* All the better to eat you with! */ - strncpy(cleanstr, buf, sizeof(cleanstr)); + /* All the better to eat you with! */ + strlcat(buf, ptr, sizeof buf); + memcpy(cleanstr, buf, sizeof cleanstr); memset(buf, 0, sizeof(buf)); regfree(&pcomp); if (matchlen == stringlen) diff --git a/src/channel.c b/src/channel.c index f63e04c88..a031103bb 100644 --- a/src/channel.c +++ b/src/channel.c @@ -539,13 +539,13 @@ extern Ban *is_banned(aClient *cptr, aClient *sptr, aChannel *chptr) s = make_nick_user_host(cptr->name, cptr->user->username, cptr->user->realhost); - strcpy(realhost, s); + strlcpy(realhost, s, sizeof realhost); if (dovirt) { s = make_nick_user_host(cptr->name, cptr->user->username, - cptr->user->virthost); - strcpy(virthost, s); + cptr->user->virthost); + strlcpy(virthost, s, sizeof virthost); } /* We now check +b first, if a +b is found we then see if there is a +e. * If a +e was found we return NULL, if not, we return the ban. @@ -811,7 +811,8 @@ static void channel_modes(aClient *cptr, char *mbuf, char *pbuf, aChannel *chptr if (IsMember(cptr, chptr) || IsServer(cptr) || IsULine(cptr)) { - (void)ircsprintf(bcbuf, "%s ", chptr->mode.key); + /* FIXME: hope pbuf is long enough */ + (void)snprintf(bcbuf, sizeof bcbuf, "%s ", chptr->mode.key); (void)strcat(pbuf, bcbuf); } } @@ -821,7 +822,8 @@ static void channel_modes(aClient *cptr, char *mbuf, char *pbuf, aChannel *chptr if (IsMember(cptr, chptr) || IsServer(cptr) || IsULine(cptr)) { - (void)ircsprintf(bcbuf, "%s ", chptr->mode.link); + /* FIXME: is pbuf long enough? */ + (void)snprintf(bcbuf, sizeof bcbuf, "%s ", chptr->mode.link); (void)strcat(pbuf, bcbuf); } } @@ -879,8 +881,8 @@ static int send_mode_list(aClient *cptr, char *chname, TS creationtime, Member * if (strlen(parabuf) + strlen(name) + 11 < (size_t)MODEBUFLEN) { if (*parabuf) - (void)strcat(parabuf, " "); - (void)strcat(parabuf, name); + (void)strlcat(parabuf, " ", sizeof parabuf); + (void)strlcat(parabuf, name, sizeof parabuf); count++; *cp++ = flag; *cp = '\0'; @@ -901,7 +903,7 @@ static int send_mode_list(aClient *cptr, char *chname, TS creationtime, Member * *cp++ = '+'; if (count != RESYNCMODES) { - (void)strcpy(parabuf, name); + (void)strlcpy(parabuf, name, sizeof parabuf); *cp++ = flag; } count = 0; @@ -2727,10 +2729,13 @@ CMD_FUNC(channel_link) continue; } if (*jbuf) - (void)strcat(jbuf, ","); - (void)strncat(jbuf, name, sizeof(jbuf) - i - 1); + (void)strlcat(jbuf, ",", sizeof jbuf); + (void)strlncat(jbuf, name, sizeof jbuf, sizeof(jbuf) - i - 1); i += strlen(name) + 1; } + /* + * FIXME: Hopefully parv[1] is long enough? + */ (void)strcpy(parv[1], jbuf); p = NULL; @@ -2963,8 +2968,8 @@ CMD_FUNC(m_join) continue; } if (*jbuf) - (void)strcat(jbuf, ","); - (void)strncat(jbuf, name, sizeof(jbuf) - i - 1); + (void)strlcat(jbuf, ",", sizeof jbuf); + (void)strlncat(jbuf, name, sizeof jbuf, sizeof(jbuf) - i - 1); i += strlen(name) + 1; } (void)strcpy(parv[1], jbuf); @@ -3933,7 +3938,7 @@ char mode_buf[MODEBUFLEN], parabuf[MODEBUFLEN]; if (mode_buf[2] == '\0') mode_buf[0] = '\0'; else - strcat(mode_buf, "]"); + strlcat(mode_buf, "]", sizeof mode_buf); #endif if (!IsAnOper(cptr)) sendto_one(cptr, @@ -4268,7 +4273,7 @@ CMD_FUNC(m_list) if (mode_buf[2] == '\0') mode_buf[0] = '\0'; else - strcat(mode_buf, "]"); + strlcat(mode_buf, "]", sizeof mode_buf); #endif sendto_one(sptr, rpl_str(RPL_LIST), @@ -4442,7 +4447,7 @@ void send_user_joins(aClient *cptr, aClient *user) int cnt = 0, len = 0, clen; char *mask; - ircsprintf(buf, ":%s %s ", user->name, + snprintf(buf, sizeof buf, ":%s %s ", user->name, (IsToken(cptr) ? TOK_JOIN : MSG_JOIN)); len = strlen(buf); @@ -4462,18 +4467,18 @@ void send_user_joins(aClient *cptr, aClient *user) buf[len - 1] = '\0'; sendto_one(cptr, "%s", buf); } - ircsprintf(buf, ":%s %s ", user->name, + snprintf(buf, sizeof buf, ":%s %s ", user->name, (IsToken(cptr) ? TOK_JOIN : MSG_JOIN)); len = strlen(buf); cnt = 0; } - (void)strcpy(buf + len, chptr->chname); + (void)strlcpy(buf + len, chptr->chname, sizeof buf-len); cnt++; len += clen; if (lp->next) { len++; - (void)strcat(buf, ","); + (void)strlcat(buf, ",", sizeof buf); } } if (*buf && cnt) @@ -4672,8 +4677,8 @@ else if (b == MAXMODEPARAMS) {\ } #define Addsingle(x) modebuf[b] = x; b++ #define CheckStatus(x,y) if (modeflags & (y)) { Addit((x), nick); } -#define AddBan(x) strcat(banbuf, x); strcat(banbuf, " "); -#define AddEx(x) strcat(exbuf, x); strcat(exbuf, " "); +#define AddBan(x) strlcat(banbuf, x, sizeof banbuf); strlcat(banbuf, " ", sizeof banbuf); +#define AddEx(x) strlcat(exbuf, x, sizeof exbuf); strlcat(exbuf, " ", sizeof banbuf); CMD_FUNC(m_sjoin) @@ -4853,7 +4858,7 @@ CMD_FUNC(m_sjoin) b = 1; c = 0; bp = buf; - strcpy(cbuf, parv[parc-1]); + strlcpy(cbuf, parv[parc-1], sizeof cbuf); for (s = s0 = strtoken(&p, cbuf, " "); s; s = s0 = strtoken(&p, (char *)NULL, " ")) { @@ -4986,15 +4991,15 @@ CMD_FUNC(m_sjoin) if (!merge && !removetheirs && !nomode) { - strcpy(modebuf, parv[3]); + strlcpy(modebuf, parv[3], sizeof modebuf); parabuf[0] = '\0'; if (!nopara) for (b = 4; b <= (parc - 2); b++) { - strcat(parabuf, parv[b]); - strcat(parabuf, " "); + strlcat(parabuf, parv[b], sizeof parabuf); + strlcat(parabuf, " ", sizeof parabuf); } - strcpy(paraback, parabuf); + strlcpy(paraback, parabuf, sizeof paraback); ap = mp2parv(modebuf, parabuf); set_mode(chptr, cptr, ap->parc, ap->parv, &pcount, pvar, 0); sendto_serv_butone_sjoin(cptr, @@ -5009,13 +5014,13 @@ CMD_FUNC(m_sjoin) aCtab *acp; bcopy(&chptr->mode, &oldmode, sizeof(Mode)); /* merge the modes */ - strcpy(modebuf, parv[3]); + strlcpy(modebuf, parv[3], sizeof modebuf); parabuf[0] = '\0'; if (!nopara) for (b = 4; b <= (parc - 2); b++) { - strcat(parabuf, parv[b]); - strcat(parabuf, " "); + strlcat(parabuf, parv[b], sizeof parabuf); + strlcat(parabuf, " ", sizeof parabuf); } ap = mp2parv(modebuf, parabuf); set_mode(chptr, cptr, ap->parc, ap->parv, &pcount, pvar, 0); @@ -5024,7 +5029,7 @@ CMD_FUNC(m_sjoin) We first see if any para modes are set */ - strcpy(modebuf, "-"); + strlcpy(modebuf, "-", sizeof modebuf); parabuf[0] = '\0'; b = 1; /* however, is this really going to happen at all? may be unneeded */ @@ -5064,7 +5069,7 @@ CMD_FUNC(m_sjoin) } else { - strcpy(modebuf, "+"); + strlcpy(modebuf, "+", sizeof modebuf); b = 1; } for (acp = cFlagTab; acp->mode; acp++) @@ -5120,7 +5125,7 @@ CMD_FUNC(m_sjoin) z = MAX(x, y); if (z == x) { - strcpy(chptr->mode.key, oldmode.key); + strlcpy(chptr->mode.key, oldmode.key, sizeof chptr->mode.key); } else { @@ -5136,7 +5141,7 @@ CMD_FUNC(m_sjoin) z = MAX(x, y); if (z == x) { - strcpy(chptr->mode.link, oldmode.link); + strlcpy(chptr->mode.link, oldmode.link, sizeof(chptr->mode.link)); } else { @@ -5187,7 +5192,7 @@ CMD_FUNC(m_sjoin) oldts, chptr->creationtime); - strcpy(parabuf, ""); + strlcpy(parabuf, "", sizeof parabuf); for (i = 2; i <= (parc - 2); i++) { if (!parv[i]) @@ -5195,9 +5200,9 @@ CMD_FUNC(m_sjoin) sendto_ops("Got null parv in SJ3 code"); continue; } - strcat(parabuf, parv[i]); + strlcat(parabuf, parv[i], sizeof parabuf); if (((i + 1) <= (parc - 2))) - strcat(parabuf, " "); + strlcat(parabuf, " ", sizeof parabuf); } if (!chptr->users) { @@ -5260,7 +5265,7 @@ static int send_ban_list(aClient *cptr, char *chname, TS creationtime, aChannel *cp++ = '+'; if (count != MODEPARAMS) { - (void)strcpy(parabuf, name); + (void)strlcpy(parabuf, name, sizeof parabuf); *cp++ = 'b'; } count = 0; @@ -5298,7 +5303,7 @@ static int send_ban_list(aClient *cptr, char *chname, TS creationtime, aChannel *cp++ = '+'; if (count != MODEPARAMS) { - (void)strcpy(parabuf, name); + (void)strlcpy(parabuf, name, sizeof parabuf); *cp++ = 'e'; } count = 0; @@ -5339,9 +5344,9 @@ void send_channel_modes_sjoin(aClient *cptr, aChannel *chptr) else { if (!SupportSJOIN2(cptr)) - strcpy(parabuf, ""); + strlcpy(parabuf, "", sizeof parabuf); else - strcpy(parabuf, "<->"); + strlcpy(parabuf, "<->", sizeof parabuf); } ircsprintf(buf, "%s %ld %s %s %s :", (IsToken(cptr) ? TOK_SJOIN : MSG_SJOIN), diff --git a/src/cloak.c b/src/cloak.c index 6e5a938a4..e8f8e9ba9 100644 --- a/src/cloak.c +++ b/src/cloak.c @@ -203,7 +203,8 @@ char *hidehost(char *host) #else l[i] = ((l[i] + KEY2) ^ KEY) + KEY3; #endif - l[i] <<= 2; l[i] >>= 2; + + l[i] &= 0x3FFFFFFF; } ircsprintf(cloaked, "%lx:%lx:%lx:IP", l[2], l[1], l[0]); @@ -220,7 +221,7 @@ char *hidehost(char *host) if (!(*p)) { /* Do IPv4 cloaking here */ - strcpy(h1, host); + strlcpy(h1, host, sizeof h1); i = 0; for (i = 0, p = strtok(h1, "."); p && (i <= 3); p = strtok(NULL, "."), i++) { @@ -241,9 +242,10 @@ char *hidehost(char *host) l[4] = crc32(host, strlen(host)); l[2] = ((l[4] + KEY) ^ KEY3)^ KEY2; #endif - l[2] <<= 2; l[2] >>= 2; - l[0] <<= 1; l[0] >>= 1; - ircsprintf(cloaked, "%lX.%lX.%lX.IP", l[2], l[1], l[0]); + l[2] &= 0x3FFFFFFF; + l[0] &= 0x7FFFFFFF; + l[1] &= 0xFFFFFFFF; + snprintf(cloaked, sizeof cloaked, "%lX.%lX.%lX.IP", l[2], l[1], l[0]); return cloaked; } else @@ -265,14 +267,13 @@ char *hidehost(char *host) #else l[0] = ((crc32(host, strlen(host)) ^ KEY2) + KEY) ^ KEY3; #endif - l[0] <<= 2; - l[0] >>= 2; + l[0] &= 0x3FFFFFFF; p++; if (*p) - sprintf(cloaked, "%s-%lX.%s", hidden_host, + snprintf(cloaked, sizeof cloaked, "%s-%lX.%s", hidden_host, l[0], p); else - sprintf(cloaked, "%s-%lX", hidden_host, l[0]); + snprintf(cloaked, sizeof cloaked, "%s-%lX", hidden_host, l[0]); return cloaked; } diff --git a/src/crule.c b/src/crule.c index 8284380ef..013d3a729 100644 --- a/src/crule.c +++ b/src/crule.c @@ -613,14 +613,14 @@ int crule_parsearglist(crule_treeptr argrootp, int *next_tokp, char **ruleptr) { if ((arglen + wordlen) < (CR_MAXARGLEN - 1)) { - strcat(currarg, " "); - strcat(currarg, word); + strlcat(currarg, " ", sizeof currarg); + strlcat(currarg, word, sizeof currarg); arglen += wordlen + 1; } } else { - strcpy(currarg, word); + strlcpy(currarg, word, sizeof currarg); arglen = wordlen; } errcode = crule_gettoken(next_tokp, ruleptr); diff --git a/src/dbuf.c b/src/dbuf.c index 25c81e9e5..7438add1a 100644 --- a/src/dbuf.c +++ b/src/dbuf.c @@ -297,7 +297,7 @@ int dbuf_getmsg(dbuf *dyn, char *buf, int length) while (length > 0 && dlen > 0) { dlen--; - if (*s == '\n' /* || *s == '\r' */ ) /*let stop at \n now .. */ + if (*s == '\n' || *s == '\r' ) { copy = dyn->length - dlen; /* diff --git a/src/ircd.c b/src/ircd.c index 4453311ce..a2e0f70ca 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -85,10 +85,10 @@ int un_gid = 99; #ifndef _WIN32 extern char unreallogo[]; #endif -int SVSNOOP = 0; +int SVSNOOP = 0; extern char *buildid; time_t timeofday = 0; -int tainted = 0; +int tainted = 0; LoopStruct loop; extern aMotd *opermotd; extern aMotd *svsmotd; @@ -171,7 +171,6 @@ TS nextconnect = 1; /* time for next try_connections call */ TS nextping = 1; /* same as above for check_pings() */ TS nextdnscheck = 0; /* next time to poll dns to force timeouts */ TS nextexpire = 1; /* next expire run on the dns cache */ -TS nextkillcheck = 1; /* next time to check for nickserv kills */ TS lastlucheck = 0; #ifdef UNREAL_DEBUG @@ -208,7 +207,7 @@ VOIDSIG s_monitor(void) VOIDSIG s_die() { #ifdef _WIN32 - int i; + int i; aClient *cptr; #endif unload_all_modules(); @@ -245,7 +244,8 @@ VOIDSIG s_rehash() #endif } -void restart(char *mesg) { +void restart(char *mesg) +{ server_reboot(mesg); } @@ -253,9 +253,10 @@ VOIDSIG s_restart() { static int restarting = 0; - if (restarting == 0) - { - /* Send (or attempt to) a dying scream to oper if present */ + if (restarting == 0) { + /* + * Send (or attempt to) a dying scream to oper if present + */ restarting = 1; server_reboot("SIGINT"); @@ -265,8 +266,7 @@ VOIDSIG s_restart() VOIDSIG s_segv(void) { - char *argv[] = - { + char *argv[] = { "./.bugreport", NULL }; @@ -310,7 +310,7 @@ VOIDSIG dummy() #endif } -#endif /* _WIN32 */ +#endif /* _WIN32 */ void server_reboot(char *mesg) @@ -329,8 +329,8 @@ void server_reboot(char *mesg) (void)send_queued(cptr); #endif /* - ** fd 0 must be 'preserved' if either the -d or -i options have - ** been passed to us before restarting. + * ** fd 0 must be 'preserved' if either the -d or -i options have + * ** been passed to us before restarting. */ #ifdef HAVE_SYSLOG (void)closelog(); @@ -363,14 +363,8 @@ char *areason; EVENT(loop_event) { - if (loop.do_tkl_sweep) - { - tkl_sweep(); - loop.do_tkl_sweep = 0; - } - if (loop.do_garbage_collect == 1) - { - garbage_collect(NULL); + if (loop.do_garbage_collect == 1) { + garbage_collect(NULL); } } @@ -380,26 +374,21 @@ EVENT(garbage_collect) extern Link *freelink; Link p; int ii; - + if (loop.do_garbage_collect == 1) sendto_realops("Doing garbage collection .."); - if (freelinks > HOW_MANY_FREELINKS_ALLOWED) - { + if (freelinks > HOW_MANY_FREELINKS_ALLOWED) { ii = freelinks; - while (freelink - && (freelinks > HOW_MANY_FREELINKS_ALLOWED)) - { + while (freelink && (freelinks > HOW_MANY_FREELINKS_ALLOWED)) { freelinks--; p.next = freelink; freelink = freelink->next; MyFree(p.next); } - if (loop.do_garbage_collect == 1) - { + if (loop.do_garbage_collect == 1) { loop.do_garbage_collect = 0; sendto_realops - ("Cleaned up %i garbage blocks", - (ii - freelinks)); + ("Cleaned up %i garbage blocks", (ii - freelinks)); } } if (loop.do_garbage_collect == 1) @@ -426,23 +415,23 @@ static TS try_connections(TS currenttime) connecting = FALSE; Debug((DEBUG_NOTICE, "Connection check at : %s", myctime(currenttime))); - for (aconf = conf_link; aconf; aconf = (ConfigItem_link *) aconf->next) - { - /* Also when already connecting! (update holdtimes) --SRB */ + for (aconf = conf_link; aconf; aconf = (ConfigItem_link *) aconf->next) { + /* + * Also when already connecting! (update holdtimes) --SRB + */ if (!(aconf->options & CONNECT_AUTO)) continue; cltmp = aconf->class; /* - ** Skip this entry if the use of it is still on hold until - ** future. Otherwise handle this entry (and set it on hold - ** until next time). Will reset only hold times, if already - ** made one successfull connection... [this algorithm is - ** a bit fuzzy... -- msa >;) ] + * ** Skip this entry if the use of it is still on hold until + * ** future. Otherwise handle this entry (and set it on hold + * ** until next time). Will reset only hold times, if already + * ** made one successfull connection... [this algorithm is + * ** a bit fuzzy... -- msa >;) ] */ - if ((aconf->hold > currenttime)) - { + if ((aconf->hold > currenttime)) { if ((next > aconf->hold) || (next == 0)) next = aconf->hold; continue; @@ -451,14 +440,15 @@ static TS try_connections(TS currenttime) confrq = cltmp->connfreq; aconf->hold = currenttime + confrq; /* - ** Found a CONNECT config with port specified, scan clients - ** and see if this server is already connected? + * ** Found a CONNECT config with port specified, scan clients + * ** and see if this server is already connected? */ cptr = find_name(aconf->servername, (aClient *)NULL); - if (!cptr && (cltmp->clients < cltmp->maxclients)) - { - /* Check connect rules to see if we're allowed to try */ + if (!cptr && (cltmp->clients < cltmp->maxclients)) { + /* + * Check connect rules to see if we're allowed to try + */ for (deny = conf_deny_link; deny; deny = (ConfigItem_deny_link *) deny->next) if (!match(deny->mask, aconf->servername) @@ -467,7 +457,8 @@ static TS try_connections(TS currenttime) if (connect_server(aconf, (aClient *)NULL, (struct hostent *)NULL) == 0) - sendto_realops("Connection to %s[%s] activated.", + sendto_realops + ("Connection to %s[%s] activated.", aconf->servername, aconf->hostname); } @@ -483,34 +474,48 @@ static TS try_connections(TS currenttime) AKILL/RAKILL/KLINE/UNKLINE/REHASH. Very significant CPU usage decrease. -- Barubary */ -extern TS check_pings(TS currenttime, int check_kills) -{ - aClient *cptr; - ConfigItem_ban *bconf = NULL; - int ping = 0, killflag = 0, i = 0; - TS oldest = 0; - static char banbuf[1024]; - for (i = 0; i <= LastSlot; i++) - { - /* If something we should not touch .. */ + +extern TS check_pings(TS currenttime) +{ + aClient *cptr = NULL; + ConfigItem_ban *bconf = NULL; + char killflag = 0; + int i = 0; + char banbuf[1024]; + int ping = 0; + TS oldest = 0; + + for (i = 0; i <= LastSlot; i++) { + /* + * If something we should not touch .. + */ if (!(cptr = local[i]) || IsMe(cptr) || IsLog(cptr)) continue; /* - ** Note: No need to notify opers here. It's - ** already done when "FLAGS_DEADSOCKET" is set. + * ** Note: No need to notify opers here. It's + * ** already done when "FLAGS_DEADSOCKET" is set. */ - if (cptr->flags & FLAGS_DEADSOCKET) - { + if (cptr->flags & FLAGS_DEADSOCKET) { (void)exit_client(cptr, cptr, &me, "Dead socket"); continue; } - bconf = NULL; - if (check_kills) - { - if (IsPerson(cptr)) - { + killflag = 0; + /* + * Check if user is banned + */ + if (loop.do_bancheck) { + if (find_tkline_match(cptr, 0) < 0) { + /* + * Client exited + */ + continue; + } + if (!killflag && IsPerson(cptr)) { + /* + * If it's a user, we check for CONF_BAN_USER + */ bconf = Find_ban(make_user_host(cptr-> user ? cptr->user->username : cptr-> @@ -518,86 +523,78 @@ extern TS check_pings(TS currenttime, int check_kills) cptr->user ? cptr->user->realhost : cptr-> sockhost), CONF_BAN_USER); if (bconf) - killflag = 1; - else - killflag = 0; - } - } - else - killflag = 0; + killflag++; + + if (!killflag && !IsAnOper(cptr) && + (bconf = + Find_ban(cptr->info, CONF_BAN_REALNAME))) { + killflag++; + } - if (check_kills && !killflag && IsPerson(cptr)) - { - if ((bconf = - Find_ban(inetntoa((char *)&cptr->ip), CONF_BAN_IP))) - { - killflag = 1; - } - if (bconf) - killflag = 1; - if (find_tkline_match(cptr, 0) < 0) - { - continue; } - if (!IsAnOper(cptr) - && (bconf = - Find_ban(cptr->info, CONF_BAN_REALNAME))) - { - killflag = 1; - } - } - if (killflag) - { - if (IsPerson(cptr)) - { - sendto_realops - ("Kill line active for %s (%s)", - get_client_name(cptr, FALSE), - bconf ? - bconf-> - reason ? bconf->reason : "no reason" : - "no reason"); - if (bconf && bconf->reason) - { - ircsprintf(banbuf, - "User has been banned (%s)", - bconf->reason); + /* + * If no cookie, we search for Z:lines + */ + if (!killflag) + if ((bconf = + Find_ban(Inet_ia2p(&cptr->ip), + CONF_BAN_IP))) + killflag++; + if (killflag) { + if (IsPerson(cptr)) + sendto_realops("Ban active for %s (%s)", + get_client_name(cptr, FALSE), + bconf->reason ? bconf-> + reason : "no reason"); + + if (IsServer(cptr)) + sendto_realops + ("Ban active for server %s (%s)", + get_client_name(cptr, FALSE), + bconf->reason ? bconf-> + reason : "no reason"); + if (bconf->reason) { + if (IsPerson(cptr)) + snprintf(banbuf, + sizeof banbuf - 1, + "User has been banned (%s)", + bconf->reason); + snprintf(banbuf, sizeof banbuf - 1, + "Banned (%s)", bconf->reason); (void)exit_client(cptr, cptr, &me, banbuf); + } else { + if (IsPerson(cptr)) + (void)exit_client(cptr, cptr, + &me, + "User has been banned"); + else + (void)exit_client(cptr, cptr, + &me, "Banned"); } - else - { - (void)exit_client(cptr, cptr, &me, - "User has been banned"); - } + continue; } - else - { - exit_client(cptr, cptr, &me, "Banned"); - } - continue; + } - /* If we go here, its a ping timeout */ + /* + * We go into ping phase + */ ping = IsRegistered(cptr) ? (cptr->class ? cptr-> class->pingfreq : CONNECTTIMEOUT) : CONNECTTIMEOUT; Debug((DEBUG_DEBUG, "c(%s)=%d p %d k %d a %d", cptr->name, cptr->status, ping, killflag, currenttime - cptr->lasttime)); - if (ping < (currenttime - cptr->lasttime)) - { + if (ping < (currenttime - cptr->lasttime)) { if (((cptr->flags & FLAGS_PINGSENT) && ((currenttime - cptr->lasttime) >= (2 * ping))) || ((!IsRegistered(cptr) && (currenttime - cptr->since) >= ping))) - { if (!IsRegistered(cptr) && (DoingDNS(cptr) || DoingAuth(cptr) - )) - { - if (cptr->authfd >= 0) - { + )) { + if (cptr->authfd >= 0) { CLOSE_SOCK(cptr->authfd); --OpenFiles; cptr->authfd = -1; @@ -616,7 +613,7 @@ extern TS check_pings(TS currenttime, int check_kills) "DNS/AUTH timeout %s", get_client_name(cptr, TRUE))); del_queries((char *)cptr); - ClearAuth(cptr); + ClearAuth(cptr); ClearDNS(cptr); SetAccess(cptr); cptr->firsttime = currenttime; @@ -624,8 +621,7 @@ extern TS check_pings(TS currenttime, int check_kills) continue; } if (IsServer(cptr) || IsConnecting(cptr) || - IsHandshake(cptr)) - { + IsHandshake(cptr)) { sendto_realops ("No response from %s, closing link", get_client_name(cptr, FALSE)); @@ -636,24 +632,23 @@ extern TS check_pings(TS currenttime, int check_kills) } exit_client(cptr, cptr, &me, "Ping timeout"); continue; - } - else if (IsRegistered(cptr) && - ((cptr->flags & FLAGS_PINGSENT) == 0)) - { + } else if (IsRegistered(cptr) && + ((cptr->flags & FLAGS_PINGSENT) == 0)) { /* * if we havent PINGed the connection and we havent * heard from it in a while, PING it to make sure * it is still alive. */ cptr->flags |= FLAGS_PINGSENT; - /* not nice but does the job */ + /* + * not nice but does the job + */ cptr->lasttime = currenttime - ping; sendto_one(cptr, "%s :%s", IsToken(cptr) ? TOK_PING : MSG_PING, me.name); } } - /* * Check UNKNOWN connections - if they have been in this state * for > 100s, close them. @@ -664,27 +659,27 @@ extern TS check_pings(TS currenttime, int check_kills) (void)exit_client(cptr, cptr, &me, "Connection Timed Out"); } - - /* EXPLANATION - * on a server with a large volume of clients, at any given point - * there may be a client which needs to be pinged the next second, - * or even right away (a second may have passed while running - * check_pings). Preserving CPU time is more important than - * pinging clients out at exact times, IMO. Therefore, I am going to make - * check_pings always return currenttime + 9. This means that it may take - * a user up to 9 seconds more than pingfreq to timeout. Oh well. - * Plus, the number is 9 to 'stagger' our check_pings calls out over - * time, to avoid doing it and the other tasks ircd does at the same time - * all the time (which are usually done on intervals of 5 seconds or so). - * - lucas - * + /* + * EXPLANATION + * * on a server with a large volume of clients, at any given point + * * there may be a client which needs to be pinged the next second, + * * or even right away (a second may have passed while running + * * check_pings). Preserving CPU time is more important than + * * pinging clients out at exact times, IMO. Therefore, I am going to make + * * check_pings always return currenttime + 9. This means that it may take + * * a user up to 9 seconds more than pingfreq to timeout. Oh well. + * * Plus, the number is 9 to 'stagger' our check_pings calls out over + * * time, to avoid doing it and the other tasks ircd does at the same time + * * all the time (which are usually done on intervals of 5 seconds or so). + * * - lucas + * * */ - - oldest = currenttime + 9; + if (loop.do_bancheck) + loop.do_bancheck = 0; Debug((DEBUG_NOTICE, "Next check_ping() call at: %s, %d %d %d", - myctime(oldest), ping, oldest, currenttime)); + myctime(currenttime+9), ping, currenttime+9, currenttime)); - return oldest; + return currenttime + 9; } /* @@ -701,7 +696,8 @@ static int bad_command(void) #define CMDLINE_CFG "" #endif (void)printf - ("Usage: ircd %s[-h servername] [-p portnumber] [-x loglevel] [-t] [-H]\n",CMDLINE_CFG); + ("Usage: ircd %s[-h servername] [-p portnumber] [-x loglevel] [-t] [-H]\n", + CMDLINE_CFG); (void)printf("Server not started\n\n"); #else MessageBox(NULL, @@ -715,19 +711,17 @@ char chess[] = { 85, 110, 114, 101, 97, 108, 0 }; #ifndef NO_FDLIST -inline TS check_fdlists(TS now) +inline TS check_fdlists(TS now) { aClient *cptr; int pri; /* temp. for priority */ int i, j; j = 0; - for (i = LastSlot; i >= 0; i--) - { + for (i = LastSlot; i >= 0; i--) { if (!(cptr = local[i])) continue; if (IsServer(cptr) || IsListening(cptr) - || IsOper(cptr) || DoingAuth(cptr)) - { + || IsOper(cptr) || DoingAuth(cptr)) { busycli_fdlist.entry[++j] = i; continue; } @@ -748,6 +742,7 @@ inline TS check_fdlists(TS now) busycli_fdlist.last_entry = j; /* rest of the fdlist is garbage */ return (now + FDLISTCHKFREQ + lifesux * FDLISTCHKFREQ); } + EVENT(e_check_fdlists) { check_fdlists(TStime()); @@ -758,9 +753,9 @@ EVENT(e_check_fdlists) extern time_t TSoffset; #ifndef _WIN32 -int main(int argc, char *argv[]) +int main(int argc, char *argv[]) #else -int InitwIRCD(int argc, char *argv[]) +int InitwIRCD(int argc, char *argv[]) #endif { #ifdef _WIN32 @@ -791,14 +786,12 @@ int InitwIRCD(int argc, char *argv[]) # endif #endif #ifdef CHROOTDIR - if (chdir(dpath)) - { + if (chdir(dpath)) { perror("chdir"); exit(-1); } ircd_res_init(); - if (chroot(DPATH)) - { + if (chroot(DPATH)) { (void)fprintf(stderr, "ERROR: Cannot chdir/chroot\n"); exit(5); } @@ -820,27 +813,22 @@ int InitwIRCD(int argc, char *argv[]) printf("unlimit core size failed; errno = %d\n", errno); #endif /* - ** All command line parameters have the syntax "-fstring" - ** or "-f string" (e.g. the space is optional). String may - ** be empty. Flag characters cannot be concatenated (like - ** "-fxyz"), it would conflict with the form "-fstring". + * ** All command line parameters have the syntax "-fstring" + * ** or "-f string" (e.g. the space is optional). String may + * ** be empty. Flag characters cannot be concatenated (like + * ** "-fxyz"), it would conflict with the form "-fstring". */ - while (--argc > 0 && (*++argv)[0] == '-') - { + while (--argc > 0 && (*++argv)[0] == '-') { char *p = argv[0] + 1; int flag = *p++; - if (flag == '\0' || *p == '\0') - { - if (argc > 1 && argv[1][0] != '-') - { + if (flag == '\0' || *p == '\0') { + if (argc > 1 && argv[1][0] != '-') { p = *++argv; argc -= 1; - } - else + } else p = ""; } - switch (flag) - { + switch (flag) { #ifndef _WIN32 case 'a': bootopt |= BOOT_AUTODIE; @@ -869,42 +857,43 @@ int InitwIRCD(int argc, char *argv[]) break; #endif case 'h': - if (!strchr(p, '.')) - { + if (!strchr(p, '.')) { (void)printf ("ERROR: %s is not valid: Server names must contain at least 1 \".\"\n", - p); exit(1); + p); + exit(1); } strncpyzt(me.name, p, sizeof(me.name)); break; #endif #ifndef _WIN32 - case 'P': { + case 'P':{ short type; char *result; srandom(TStime()); if ((type = Auth_FindType(p)) == -1) { - printf("No such auth type %s\n", p); - exit(0); + printf("No such auth type %s\n", p); + exit(0); } p = *++argv; argc--; if (!(result = Auth_Make(type, p))) { - printf("Authentication failed\n"); - exit(0); + printf("Authentication failed\n"); + exit(0); } printf("Encrypted password is: %s\n", result); exit(0); } -#endif - +#endif + case 'p': if ((portarg = atoi(p)) > 0) portnum = portarg; break; case 's': - (void)printf("sizeof(aClient) == %u\n", sizeof(aClient)); + (void)printf("sizeof(aClient) == %u\n", + sizeof(aClient)); (void)printf("sizeof(aChannel) == %u\n", sizeof(aChannel)); (void)printf("sizeof(aServer) == %u\n", @@ -917,7 +906,8 @@ int InitwIRCD(int argc, char *argv[]) (void)printf("sizeof(struct ircstatsx) == %u\n", sizeof(struct ircstatsx)); (void)printf("aClient remote == %u\n", - CLIENT_REMOTE_SIZE); exit(0); + CLIENT_REMOTE_SIZE); + exit(0); break; #ifndef _WIN32 case 't': @@ -932,19 +922,19 @@ int InitwIRCD(int argc, char *argv[]) "UnrealIRCD/Win32 version", MB_OK); #endif exit(0); - case 'W': { - struct IN_ADDR bah; - int bit; - parse_netmask("255.255.255.255/8", &bah, &bit); - printf("%s - %d\n",Inet_ia2p(&bah), bit); - flag_add("m"); - flag_del('m'); - flag_add("n"); - flag_add("m"); - flag_del('m'); - printf("%s\n", extraflags); - exit(0); - } + case 'W':{ + struct IN_ADDR bah; + int bit; + parse_netmask("255.255.255.255/8", &bah, &bit); + printf("%s - %d\n", Inet_ia2p(&bah), bit); + flag_add("m"); + flag_del('m'); + flag_add("n"); + flag_add("m"); + flag_del('m'); + printf("%s\n", extraflags); + exit(0); + } case 'C': conf_debuglevel = atoi(p); break; @@ -976,8 +966,7 @@ int InitwIRCD(int argc, char *argv[]) } #ifndef CHROOT - if (chdir(dpath)) - { + if (chdir(dpath)) { # ifndef _WIN32 perror("chdir"); # else @@ -989,8 +978,7 @@ int InitwIRCD(int argc, char *argv[]) #endif #if !defined(IRC_UID) && !defined(_WIN32) - if ((uid != euid) && !euid) - { + if ((uid != euid) && !euid) { (void)fprintf(stderr, "ERROR: do not run ircd setuid root. Make it setuid a\ normal user.\n"); @@ -1008,40 +996,47 @@ int InitwIRCD(int argc, char *argv[]) * Modified 13/2000 DrBin * We need to have better controll over running as root ... see config.h */ - if ((int)getuid() == 0) - { + if ((int)getuid() == 0) { #ifndef BIG_SECURITY_HOLE - if ((IRC_UID == 0) || (IRC_GID == 0)) - { - (void)fprintf(stderr, "ERROR: SETUID and SETGID have not been set properly" + if ((IRC_UID == 0) || (IRC_GID == 0)) { + (void)fprintf(stderr, + "ERROR: SETUID and SETGID have not been set properly" "\nPlease read your documentation\n(HINT:SETUID or SETGID can not be 0)\n"); exit(-1); - } - else - { - /* run as a specified user */ + } else { + /* + * run as a specified user + */ - (void)fprintf(stderr, "WARNING: ircd invoked as root\n"); - (void)fprintf(stderr, " changing to uid %d\n", IRC_UID); - (void)fprintf(stderr, " changing to gid %d\n", IRC_GID); + (void)fprintf(stderr, + "WARNING: ircd invoked as root\n"); + (void)fprintf(stderr, " changing to uid %d\n", + IRC_UID); + (void)fprintf(stderr, " changing to gid %d\n", + IRC_GID); (void)setgid(IRC_GID); - (void)setuid(IRC_UID); + (void)setuid(IRC_UID); } #else - /* check for setuid root as usual */ + /* + * check for setuid root as usual + */ (void)fprintf(stderr, "ERROR: do not run ircd setuid root. Make it setuid a\ normal user.\n"); exit(-1); # endif } -#endif /*CHROOTDIR/UID/GID/_WIN32 */ +#endif /*CHROOTDIR/UID/GID/_WIN32 */ #ifndef _WIN32 - /* didn't set debuglevel */ - /* but asked for debugging output to tty */ - if ((debuglevel < 0) && (bootopt & BOOT_TTY)) - { + /* + * didn't set debuglevel + */ + /* + * but asked for debugging output to tty + */ + if ((debuglevel < 0) && (bootopt & BOOT_TTY)) { (void)fprintf(stderr, "you specified -t without -x. use -x \n"); exit(-1); @@ -1051,7 +1046,7 @@ int InitwIRCD(int argc, char *argv[]) if (argc > 0) return bad_command(); /* This should exit out */ #ifndef _WIN32 - fprintf(stderr, unreallogo); + fprintf(stderr, "%s", unreallogo); #endif fprintf(stderr, " v%s\n\n", VERSIONONLY); clear_client_hash_table(); @@ -1065,20 +1060,23 @@ int InitwIRCD(int argc, char *argv[]) booted = FALSE; /* Hack to stop people from being able to read the config file */ #if !defined(_WIN32) && !defined(_AMIGA) && DEFAULT_PERMISSIONS != 0 - chmod(CPATH,DEFAULT_PERMISSIONS); + chmod(CPATH, DEFAULT_PERMISSIONS); #endif init_dynconf(); -#ifdef STATIC_LINKING +#ifdef STATIC_LINKING { ModuleInfo ModCoreInfo; ModCoreInfo.size = sizeof(ModuleInfo); ModCoreInfo.module_load = 0; ModCoreInfo.handle = NULL; - l_commands_Init(&ModCoreInfo); + l_commands_Init(&ModCoreInfo); } #endif - /* Add default class */ - default_class = (ConfigItem_class *) MyMallocEx(sizeof(ConfigItem_class)); + /* + * Add default class + */ + default_class = + (ConfigItem_class *) MyMallocEx(sizeof(ConfigItem_class)); default_class->flag.permanent = 1; default_class->pingfreq = PINGFREQUENCY; default_class->maxclients = 100; @@ -1123,10 +1121,14 @@ int InitwIRCD(int argc, char *argv[]) #ifdef HAVE_SYSLOG openlog("ircd", LOG_PID | LOG_NDELAY, LOG_DAEMON); #endif - /* Put in our info */ + /* + * Put in our info + */ strncpyzt(me.info, conf_me->info, sizeof(me.info)); strncpyzt(me.name, conf_me->name, sizeof(me.name)); - /* We accept the first listen record */ + /* + * We accept the first listen record + */ portnum = conf_listen->port; /* * This is completely unneeded-Sts @@ -1153,7 +1155,9 @@ int InitwIRCD(int argc, char *argv[]) me.user = NULL; me.from = &me; me.class = (ConfigItem_class *) conf_listen; - /* This listener will never go away */ + /* + * This listener will never go away + */ conf_listen->clients++; me_hash = find_or_add(me.name); me.serv->up = me_hash; @@ -1184,6 +1188,7 @@ int InitwIRCD(int argc, char *argv[]) write_pidfile(); Debug((DEBUG_NOTICE, "Server ready...")); SetupEvents(); + loop.do_bancheck = 0; loop.ircd_booted = 1; #if defined(HAVE_SETPROCTITLE) setproctitle("%s", me.name); @@ -1196,14 +1201,12 @@ int InitwIRCD(int argc, char *argv[]) #endif module_loadall(0); #ifdef STATIC_LINKING - l_commands_Load(0); + l_commands_Load(0); #endif #ifndef NO_FDLIST check_fdlists(TStime()); #endif - nextkillcheck = TStime() + (TS)1; - #ifdef _WIN32 return 1; @@ -1218,9 +1221,13 @@ void SocketLoop(void *dummy) #ifndef NO_FDLIST TS nextfdlistcheck = 0; /*end of priority code */ #endif - + while (1) #else + /* + * Forever drunk .. forever drunk .. + * * (Sorry Alphaville.) + */ for (;;) #endif { @@ -1228,17 +1235,17 @@ void SocketLoop(void *dummy) oldtimeofday = timeofday; timeofday = time(NULL) + TSoffset; - if (timeofday - oldtimeofday < 0) - { - sendto_realops("Time running backwards! %i-%i<0", timeofday, oldtimeofday); + if (timeofday - oldtimeofday < 0) { + sendto_realops("Time running backwards! %i-%i<0", + timeofday, oldtimeofday); } LockEventSystem(); DoEvents(); UnlockEventSystem(); /* - ** Run through the hashes and check lusers every - ** second - ** also check for expiring glines + * ** Run through the hashes and check lusers every + * ** second + * ** also check for expiring glines */ #ifndef NO_FDLIST @@ -1250,26 +1257,26 @@ void SocketLoop(void *dummy) if (IRCstats.me_clients > IRCstats.me_max) IRCstats.me_max = IRCstats.me_clients; /* - ** We only want to connect if a connection is due, - ** not every time through. Note, if there are no - ** active C lines, this call to Tryconnections is - ** made once only; it will return 0. - avalon + * ** We only want to connect if a connection is due, + * ** not every time through. Note, if there are no + * ** active C lines, this call to Tryconnections is + * ** made once only; it will return 0. - avalon */ if (nextconnect && timeofday >= nextconnect) nextconnect = try_connections(timeofday); /* - ** DNS checks. One to timeout queries, one for cache expiries. + * ** DNS checks. One to timeout queries, one for cache expiries. */ if (timeofday >= nextdnscheck) nextdnscheck = timeout_query_list(timeofday); if (timeofday >= nextexpire) nextexpire = expire_cache(timeofday); - /* - ** take the smaller of the two 'timed' event times as - ** the time of next event (stops us being late :) - avalon - ** WARNING - nextconnect can return 0! - */ - if (nextconnect) + /* + * ** take the smaller of the two 'timed' event times as + * ** the time of next event (stops us being late :) - avalon + * ** WARNING - nextconnect can return 0! + */ + if (nextconnect) delay = MIN(nextping, nextconnect); else delay = nextping; @@ -1277,13 +1284,13 @@ void SocketLoop(void *dummy) delay = MIN(nextexpire, delay); delay -= timeofday; /* - ** Adjust delay to something reasonable [ad hoc values] - ** (one might think something more clever here... --msa) - ** We don't really need to check that often and as long - ** as we don't delay too long, everything should be ok. - ** waiting too long can cause things to timeout... - ** i.e. PINGS -> a disconnection :( - ** - avalon + * ** Adjust delay to something reasonable [ad hoc values] + * ** (one might think something more clever here... --msa) + * ** We don't really need to check that often and as long + * ** as we don't delay too long, everything should be ok. + * ** waiting too long can cause things to timeout... + * ** i.e. PINGS -> a disconnection :( + * ** - avalon */ if (delay < 1) delay = 1; @@ -1294,59 +1301,59 @@ void SocketLoop(void *dummy) #else (void)read_message(0, &serv_fdlist); /* servers */ (void)read_message(1, &busycli_fdlist); /* busy clients */ - if (lifesux) - { + if (lifesux) { static time_t alllasttime = 0; (void)read_message(1, &serv_fdlist); - /* read servs more often */ - if (lifesux > 9) /* life really sucks */ - { + /* + * read servs more often + */ + if (lifesux > 9) { /* life really sucks */ (void)read_message(1, &busycli_fdlist); (void)read_message(1, &serv_fdlist); } flush_fdlist_connections(&serv_fdlist); timeofday = time(NULL) + TSoffset; - if ((alllasttime + (lifesux + 1)) > timeofday) - { + if ((alllasttime + (lifesux + 1)) > timeofday) { read_message(delay, NULL); /* check everything */ alllasttime = timeofday; } - } - else - { + } else { read_message(delay, NULL); /* check everything */ } #endif - /*Debug((DEBUG_DEBUG, "Got message(s)")); */ /* - ** ...perhaps should not do these loops every time, - ** but only if there is some chance of something - ** happening (but, note that conf->hold times may - ** be changed elsewhere--so precomputed next event - ** time might be too far away... (similarly with - ** ping times) --msa + * Debug((DEBUG_DEBUG, "Got message(s)")); + */ + /* + * ** ...perhaps should not do these loops every time, + * ** but only if there is some chance of something + * ** happening (but, note that conf->hold times may + * ** be changed elsewhere--so precomputed next event + * ** time might be too far away... (similarly with + * ** ping times) --msa */ #ifdef NO_FDLIST - if (timeofday >= nextping) + if (timeofday >= nextping || loop.do_bancheck) #else - if (timeofday >= nextping && !lifesux) + if ((timeofday >= nextping && !lifesux) || loop.do_bancheck) #endif - nextping = check_pings(timeofday, 0); - if (dorehash) - { + nextping = check_pings(timeofday); + if (dorehash) { (void)rehash(&me, &me, 1); dorehash = 0; } /* - ** Flush output buffers on all connections timeofday if they - ** have data in them (or at least try to flush) - ** -avalon + * ** Flush output buffers on all connections timeofday if they + * ** have data in them (or at least try to flush) + * ** -avalon */ #ifndef NO_FDLIST - /* check which clients are active */ + /* + * check which clients are active + */ if (timeofday > nextfdlistcheck) nextfdlistcheck = check_fdlists(timeofday); #endif @@ -1369,33 +1376,32 @@ static void open_debugfile(void) #ifdef DEBUGMODE int fd; aClient *cptr; - if (debuglevel >= 0) - { + if (debuglevel >= 0) { cptr = make_client(NULL, NULL); cptr->fd = 2; SetLog(cptr); cptr->port = debuglevel; cptr->flags = 0; cptr->listener = cptr; - /* local[2] = cptr; winlocal */ - (void)strcpy(cptr->sockhost, me.sockhost); + /* + * local[2] = cptr; winlocal + */ + (void)strlcpy(cptr->sockhost, me.sockhost, + sizeof cptr->sockhost); # ifndef _WIN32 (void)printf("isatty = %d ttyname = %#x\n", isatty(2), (u_int)ttyname(2)); - if (!(bootopt & BOOT_TTY)) /* leave debugging output on fd 2 */ - { + if (!(bootopt & BOOT_TTY)) { /* leave debugging output on fd 2 */ (void)truncate(LOGFILE, 0); if ((fd = open(LOGFILE, O_WRONLY | O_CREAT, 0600)) < 0) if ((fd = open("/dev/null", O_WRONLY)) < 0) exit(-1); - if (fd != 2) - { + if (fd != 2) { (void)dup2(fd, 2); (void)close(fd); } strncpyzt(cptr->name, LOGFILE, sizeof(cptr->name)); - } - else if (isatty(2) && ttyname(2)) + } else if (isatty(2) && ttyname(2)) strncpyzt(cptr->name, ttyname(2), sizeof(cptr->name)); else # endif @@ -1403,11 +1409,12 @@ static void open_debugfile(void) Debug((DEBUG_FATAL, "Debug: File <%s> Level: %d at %s", cptr->name, cptr->port, myctime(time(NULL)))); - } - else - /* local[2] = NULL; winlocal */ + } else + /* + * local[2] = NULL; winlocal + */ #endif - return; + return; } static void setup_signals() @@ -1463,13 +1470,13 @@ static void setup_signals() #endif #ifdef RESTARTING_SYSTEMCALLS /* - ** At least on Apollo sr10.1 it seems continuing system calls - ** after signal is the default. The following 'siginterrupt' - ** should change that default to interrupting calls. + * ** At least on Apollo sr10.1 it seems continuing system calls + * ** after signal is the default. The following 'siginterrupt' + * ** should change that default to interrupting calls. */ (void)siginterrupt(SIGALRM, 1); #endif #else - (void)signal(SIGSEGV,CleanUpSegv); + (void)signal(SIGSEGV, CleanUpSegv); #endif } diff --git a/src/modules/m_akill.c b/src/modules/m_akill.c index b2c7f8acc..8010a283e 100644 --- a/src/modules/m_akill.c +++ b/src/modules/m_akill.c @@ -211,7 +211,6 @@ DLLFUNC int m_akill(aClient *cptr, aClient *sptr, int parc, char *parv[]) sendto_serv_butone(cptr, ":%s AKILL %s %s", IsServer(cptr) ? parv[0] : me.name, hostmask, usermask); - - check_pings(TStime(), 1); + loop.do_bancheck = 1; return 0; } diff --git a/src/modules/m_guest.c b/src/modules/m_guest.c index 1742d1758..f3a7ba01e 100644 --- a/src/modules/m_guest.c +++ b/src/modules/m_guest.c @@ -114,20 +114,20 @@ int m_guest_Unload(int module_unload) DLLFUNC int m_guest(aClient *cptr, aClient *sptr, int parc, char *parv[]) { -int randnum; -char guestnick[NICKLEN]; -char *param[2]; + int randnum; + char guestnick[NICKLEN]; + char *param[2]; -randnum = 1+(int) (99999.0*rand()/(RAND_MAX+10000.0)); -snprintf(guestnick, NICKLEN, "Guest%d", randnum); + randnum = 1+(int) (99999.0*rand()/(RAND_MAX+10000.0)); + snprintf(guestnick, NICKLEN, "Guest%d", randnum); -while(find_client(guestnick, (aClient *)NULL)) -{ -randnum = 1+(int) (99999.0*rand()/(RAND_MAX+10000.0)); -snprintf(guestnick, NICKLEN, "Guest%d", randnum); -} -param[0] = sptr->name; -param[1] = guestnick; -m_nick(sptr,cptr,2,param); + while(find_client(guestnick, (aClient *)NULL)) + { + randnum = 1+(int) (99999.0*rand()/(RAND_MAX+10000.0)); + snprintf(guestnick, NICKLEN, "Guest%d", randnum); + } + param[0] = sptr->name; + param[1] = guestnick; + m_nick(sptr,cptr,2,param); return 0; } diff --git a/src/modules/m_kill.c b/src/modules/m_kill.c index 59a42d57c..d55719a18 100644 --- a/src/modules/m_kill.c +++ b/src/modules/m_kill.c @@ -151,7 +151,7 @@ DLLFUNC int m_kill(aClient *cptr, aClient *sptr, int parc, char *parv[]) user = parv[1]; path = parv[2]; /* Either defined or NULL (parc >= 2!!) */ - strcpy(inpath, oinpath); + strlcpy(inpath, oinpath, sizeof inpath); #ifndef ROXnet if (IsServer(cptr) && (s = (char *)index(inpath, '.')) != NULL) @@ -245,9 +245,9 @@ DLLFUNC int m_kill(aClient *cptr, aClient *sptr, int parc, char *parv[]) ** ...!operhost!oper ** ...!operhost!oper (comment) */ - strcpy(inpath, + strlcpy(inpath, IsHidden(cptr) ? cptr->user->virthost : cptr->user-> - realhost); + realhost, sizeof inpath); if (kcount < 2) { /* Only check the path the first time around, or it gets appended to itself. */ if (!BadPtr(path)) diff --git a/src/modules/m_kline.c b/src/modules/m_kline.c index 27978a114..601e1d71b 100644 --- a/src/modules/m_kline.c +++ b/src/modules/m_kline.c @@ -148,11 +148,9 @@ DLLFUNC int m_kline(aClient *cptr, aClient *sptr, int parc, char *parv[]) { *hosttemp = 0; hosttemp++; - bzero(name, sizeof(name)); - bzero(uhost, sizeof(uhost)); + strlcpy(name, parv[1], sizeof name); + strlcpy(uhost, hosttemp, sizeof uhost); - strncpy(name, parv[1], sizeof(name) - 1); - strncpy(uhost, hosttemp, sizeof(uhost) - 1); if (name[0] == '\0' || uhost[0] == '\0') { @@ -200,7 +198,7 @@ DLLFUNC int m_kline(aClient *cptr, aClient *sptr, int parc, char *parv[]) if (!acptr->user) return 0; - strcpy(name, acptr->user->username); + strlcpy(name, acptr->user->username, sizeof name); if (MyClient(acptr)) host = acptr->sockhost; else @@ -217,8 +215,14 @@ DLLFUNC int m_kline(aClient *cptr, aClient *sptr, int parc, char *parv[]) /* Add some wildcards */ + /* + * sscanf is bad :/ at least make host < uhost + */ + if (strlen(host) > sizeof uhost) + host[sizeof uhost - 1] = '\0'; + + strlcpy(uhost, host, sizeof uhost); - strcpy(uhost, host); if (isdigit(host[strlen(host) - 1])) { if (sscanf(host, "%d.%d.%d.%*d", &ip1, &ip2, &ip3)) @@ -242,6 +246,6 @@ DLLFUNC int m_kline(aClient *cptr, aClient *sptr, int parc, char *parv[]) bconf->reason = parv[2] ? strdup(parv[2]) : NULL; bconf->flag.type2 = CONF_BAN_TYPE_TEMPORARY; AddListItem(bconf, conf_ban); - check_pings(TStime(), 1); + loop.do_bancheck = 1; return 0; } diff --git a/src/modules/m_oper.c b/src/modules/m_oper.c index 9506957a8..d80836477 100644 --- a/src/modules/m_oper.c +++ b/src/modules/m_oper.c @@ -69,8 +69,6 @@ static oper_oflag_t oper_oflags[] = { "is now a co administrator (C)" }, { OFLAG_ISGLOBAL, &UMODE_OPER, &oper_host, "is now an operator (O)" }, -/* { 0xFFFFFFFF, &UMODE_LOCOP, &locop_host, - "is now a local operator (o)" }, */ { OFLAG_HELPOP, &UMODE_HELPOP, 0 , 0 }, { OFLAG_GLOBOP, &UMODE_FAILOP, 0 , @@ -79,8 +77,6 @@ static oper_oflag_t oper_oflags[] = { 0 }, { OFLAG_WHOIS, &UMODE_WHOIS, 0 , 0 }, - { OFLAG_HIDE, &UMODE_HIDE, 0 , - 0 }, { 0, 0, 0 , 0 }, }; @@ -192,8 +188,8 @@ DLLFUNC int m_oper(aClient *cptr, aClient *sptr, int parc, char *parv[]) { sptr->since += 7; return 0; } - strcpy(nuhhost, make_user_host(sptr->user->username, sptr->user->realhost)); - strcpy(nuhhost2, make_user_host(sptr->user->username, Inet_ia2p(&sptr->ip))); + strlcpy(nuhhost, make_user_host(sptr->user->username, sptr->user->realhost), sizeof(nuhhost)); + strlcpy(nuhhost2, make_user_host(sptr->user->username, Inet_ia2p(&sptr->ip)), sizeof(nuhhost2)); for (oper_from = (ConfigItem_oper_from *) aconf->from; oper_from; oper_from = (ConfigItem_oper_from *) oper_from->next) if (!match(oper_from->name, nuhhost) || !match(oper_from->name, nuhhost2)) @@ -256,6 +252,7 @@ DLLFUNC int m_oper(aClient *cptr, aClient *sptr, int parc, char *parv[]) { if ((aconf->oflags & OFLAG_HIDE) && iNAH && !BadPtr(host)) { iNAH_host(sptr, host); + SetHidden(sptr); } if (!IsOper(sptr)) diff --git a/src/modules/m_rakill.c b/src/modules/m_rakill.c index af8838b68..8dd8a1cd8 100644 --- a/src/modules/m_rakill.c +++ b/src/modules/m_rakill.c @@ -213,6 +213,6 @@ DLLFUNC int m_rakill(aClient *cptr, aClient *sptr, int parc, char *parv[]) sendto_serv_butone(cptr, ":%s RAKILL %s %s", IsServer(cptr) ? parv[0] : me.name, hostmask, usermask); - check_pings(TStime(), 1); + loop.do_bancheck = 1; return 0; } diff --git a/src/modules/m_svsmode.c b/src/modules/m_svsmode.c index 92960f5a4..81b8cbafa 100644 --- a/src/modules/m_svsmode.c +++ b/src/modules/m_svsmode.c @@ -200,10 +200,12 @@ int channel_svsmode(aClient *cptr, aClient *sptr, int parc, char *parv[]) } i++; - strcpy(uhost, make_nick_user_host(acptr->name, - acptr->user->username, acptr->user->realhost)); - strcpy(vhost, make_nick_user_host(acptr->name, - acptr->user->username, acptr->user->virthost ? acptr->user->virthost : acptr->user->realhost)); + strlcpy(uhost, make_nick_user_host(acptr->name, + acptr->user->username, acptr->user->realhost), + sizeof uhost); + strlcpy(vhost, make_nick_user_host(acptr->name, + acptr->user->username, acptr->user->virthost ? acptr->user->virthost : acptr->user->realhost), + sizeof vhost); ban = chptr->banlist; while (ban) { bnext = ban->next; @@ -240,12 +242,13 @@ int channel_svsmode(aClient *cptr, aClient *sptr, int parc, char *parv[]) } i++; - strcpy(uhost, make_nick_user_host(acptr->name, - acptr->user->username, acptr->user->realhost)); - strcpy(vhost, make_nick_user_host(acptr->name, + strlcpy(uhost, make_nick_user_host(acptr->name, + acptr->user->username, acptr->user->realhost), + sizeof uhost); + strlcpy(vhost, make_nick_user_host(acptr->name, acptr->user->username, acptr->user->virthost ? acptr->user->virthost : - acptr->user->realhost)); + acptr->user->realhost), sizeof vhost); ban = chptr->exlist; while (ban) { bnext = ban->next; diff --git a/src/modules/m_svsnick.c b/src/modules/m_svsnick.c index 1b5ac8495..a4bcb5734 100644 --- a/src/modules/m_svsnick.c +++ b/src/modules/m_svsnick.c @@ -140,7 +140,7 @@ int m_svsnick(aClient *cptr, aClient *sptr, int parc, char *parv[]) { RunHook2(HOOKTYPE_LOCAL_NICKCHANGE, acptr, parv[2]); } - (void)strcpy(acptr->name, parv[2]); + (void)strlcpy(acptr->name, parv[2], sizeof acptr->name); (void)add_to_client_hash_table(parv[2], acptr); if (IsPerson(acptr)) hash_check_watch(acptr, RPL_LOGON); diff --git a/src/modules/m_unkline.c b/src/modules/m_unkline.c index 101f7c989..c9b1696b4 100644 --- a/src/modules/m_unkline.c +++ b/src/modules/m_unkline.c @@ -180,6 +180,8 @@ DLLFUNC int m_unkline(aClient *cptr, aClient *sptr, int parc, char *parv[]) return 0; } /* This wasn't here before -- Barubary */ - check_pings(TStime(), 1); + /* check_pings crap */ + /* No, and it shouldn't have been, dork. It crashes the IRCd randomly. -Stskeeps */ + loop.do_bancheck = 1; return 0; } diff --git a/src/modules/m_unzline.c b/src/modules/m_unzline.c index dbb8b47ce..5c0c2ec9a 100644 --- a/src/modules/m_unzline.c +++ b/src/modules/m_unzline.c @@ -173,7 +173,7 @@ DLLFUNC int m_unzline(aClient *cptr, aClient *sptr, int parc, char *parv[]) the same thing to remove it if they specified *@ or something... */ if ((in = index(parv[1], '@'))) { - strcpy(userhost, in + 1); + strlcpy(userhost, in + 1, sizeof userhost); in = &userhost[0]; while (*in) { @@ -189,7 +189,7 @@ DLLFUNC int m_unzline(aClient *cptr, aClient *sptr, int parc, char *parv[]) } else { - strcpy(userhost, parv[1]); + strlcpy(userhost, parv[1], sizeof userhost); in = &userhost[0]; while (*in) { diff --git a/src/modules/m_whois.c b/src/modules/m_whois.c index 45ad9cf48..d263dcf05 100644 --- a/src/modules/m_whois.c +++ b/src/modules/m_whois.c @@ -300,20 +300,20 @@ DLLFUNC int m_whois(aClient *cptr, aClient *sptr, int parc, char *parv[]) { buf[0] = '\0'; if (IsNetAdmin(acptr)) - strcat(buf, "a Network Administrator"); + strlcat(buf, "a Network Administrator", sizeof buf); else if (IsSAdmin(acptr)) - strcat(buf, "a Services Operator"); + strlcat(buf, "a Services Operator", sizeof buf); else if (IsAdmin(acptr) && !IsCoAdmin(acptr)) - strcat(buf, "a Server Administrator"); + strlcat(buf, "a Server Administrator", sizeof buf); else if (IsCoAdmin(acptr)) - strcat(buf, "a Co Administrator"); + strlcat(buf, "a Co Administrator", sizeof buf); else if (IsServices(acptr)) - strcat(buf, "a Network Service"); + strlcat(buf, "a Network Service", sizeof buf); else if (IsOper(acptr)) - strcat(buf, "an IRC Operator"); + strlcat(buf, "an IRC Operator", sizeof buf); else - strcat(buf, "a Local IRC Operator"); + strlcat(buf, "a Local IRC Operator", sizeof buf); if (buf[0]) sendto_one(sptr, rpl_str(RPL_WHOISOPERATOR), me.name, diff --git a/src/modules/m_zline.c b/src/modules/m_zline.c index aaab0e1ea..e92d59c0e 100644 --- a/src/modules/m_zline.c +++ b/src/modules/m_zline.c @@ -168,7 +168,7 @@ DLLFUNC int m_zline(aClient *cptr, aClient *sptr, int parc, char *parv[]) if ((acptr = find_client(parv[1], NULL))) { - strcpy(userhost, inetntoa((char *)&acptr->ip)); + strlcpy(userhost, inetntoa((char *)&acptr->ip), sizeof userhost); person = &acptr->name[0]; acptr = NULL; } @@ -176,7 +176,7 @@ DLLFUNC int m_zline(aClient *cptr, aClient *sptr, int parc, char *parv[]) work with ip addresses and nicks */ else if ((in = index(parv[1], '@')) && (*(in + 1) != '\0')) { - strcpy(userhost, in + 1); + strlcpy(userhost, in + 1, sizeof userhost); in = &userhost[0]; while (*in) { @@ -200,7 +200,7 @@ DLLFUNC int m_zline(aClient *cptr, aClient *sptr, int parc, char *parv[]) } else { - strcpy(userhost, parv[1]); + strlcpy(userhost, parv[1], sizeof userhost); in = &userhost[0]; while (*in) { @@ -260,22 +260,13 @@ DLLFUNC int m_zline(aClient *cptr, aClient *sptr, int parc, char *parv[]) { goto propo_label; } - if (!match(mask, inetntoa((char *)&cptr->ip))) - { - sendto_realops("Tried to zap cptr, from %s", - parv[0]); - MyFree(bconf); - } - else - { - AddListItem(bconf, conf_ban); - } + AddListItem(bconf, conf_ban); propo_label: if (propo == 1) /* propo is if a ulined server is propagating a z-line this should go after the above check */ sendto_serv_butone(cptr, ":%s ZLINE %s :%s", parv[0], parv[1], reason ? reason : ""); - check_pings(TStime(), 1); + loop.do_bancheck = 1; return 0; } diff --git a/src/modules/scan.c b/src/modules/scan.c index 35bf79751..72a90fa91 100644 --- a/src/modules/scan.c +++ b/src/modules/scan.c @@ -111,12 +111,25 @@ int m_scan_Load(int module_load) if (Scan_endpoint.SIN_PORT == 0) { + if (*conf_listen->ip == '*') { + ircd_log(LOG_ERROR, "Scan.so failed to load: set::scan::endpoint is missing"); + HooktypeDel(ScanHost,ScanModInfo.handle); + HookDel(LocConnect); + HookDel(ConfUnknown); + HookDel(ServerStats); + LockEventSystem(); + EventDel(Scannings_clean); + UnlockEventSystem(); + IRCMutexDestroy(Scannings_lock); + return MOD_FAILED; + } + #ifndef INET6 - Scan_endpoint.SIN_ADDR.S_ADDR = inet_addr("127.0.0.1"); + Scan_endpoint.SIN_ADDR.S_ADDR = inet_addr(conf_listen->ip); #else - inet_pton(AFINET, "127.0.0.1", Scan_endpoint.SIN_ADDR.S_ADDR); + inet_pton(AFINET, conf_listen->ip, Scan_endpoint.SIN_ADDR.S_ADDR); #endif - Scan_endpoint.SIN_PORT = htons(2121); + Scan_endpoint.SIN_PORT = htons(conf_listen->port); Scan_endpoint.SIN_FAMILY = AFINET; } if (Scan_BanTime == 0) @@ -159,9 +172,11 @@ int m_scan_Unload(void) HooktypeDel(ScanHost,ScanModInfo.handle); HookDel(LocConnect); HookDel(ConfUnknown); + HookDel(ServerStats); LockEventSystem(); EventDel(Scannings_clean); UnlockEventSystem(); + IRCMutexDestroy(Scannings_lock); } return ret; } @@ -249,7 +264,7 @@ EVENT(e_scan_ban) if (!sr) return; - strcpy(hostip, Inet_ia2p(&sr->in)); + strlcpy(hostip, Inet_ia2p(&sr->in), sizeof hostip); tkllayer[4] = hostip; tkllayer[5] = me.name; ircsprintf(mo, "%li", Scan_BanTime + TStime()); @@ -266,7 +281,7 @@ void Eadd_scan(struct IN_ADDR *in, char *reason) { Scan_Result *sr = (Scan_Result *) MyMalloc(sizeof(Scan_Result)); sr->in = *in; - strcpy(sr->reason, reason); + strlcpy(sr->reason, reason, sizeof sr->reason); LockEventSystem(); EventAddEx(ScanModInfo.handle, "scan_ban", 0, 1, e_scan_ban, (void *)sr); UnlockEventSystem(); @@ -286,7 +301,6 @@ DLLFUNC int h_scan_connect(aClient *sptr) Scan_AddrStruct *sr = NULL; Hook *hook = NULL; THREAD thread; - THREAD_ATTR thread_attr; if (Find_except(Inet_ia2p(&sptr->ip), 0)) return 0; @@ -307,7 +321,7 @@ DLLFUNC int h_scan_connect(aClient *sptr) { IRCMutexLock(sr->lock); sr->refcnt++; - IRCCreateThread(thread, thread_attr, (hook->func.voidfunc), sr); + IRCCreateThread(thread, (hook->func.voidfunc), sr); IRCMutexUnlock(sr->lock); } return 1; diff --git a/src/modules/scan_http.c b/src/modules/scan_http.c index 33e945f0d..33b63f223 100644 --- a/src/modules/scan_http.c +++ b/src/modules/scan_http.c @@ -147,7 +147,6 @@ int scan_http_Unload(int module_unload) void scan_http_scan(Scan_AddrStruct *h) { THREAD thread[3]; - THREAD_ATTR thread_attr; HSStruct *p = NULL; IRCMutexLock((h->lock)); @@ -156,19 +155,19 @@ void scan_http_scan(Scan_AddrStruct *h) p = MyMalloc(sizeof(HSStruct)); p->hs = h; p->port = 3128; - IRCCreateThread(thread[0], thread_attr, scan_http_scan_port, p); + IRCCreateThread(thread[0], scan_http_scan_port, p); /* Then we take 8080 .. */ h->refcnt++; p = MyMalloc(sizeof(HSStruct)); p->hs = h; p->port = 8080; - IRCCreateThread(thread[1], thread_attr, scan_http_scan_port, p); + IRCCreateThread(thread[1], scan_http_scan_port, p); /* And then we try to infect them with Code Red .. */ h->refcnt++; p = MyMalloc(sizeof(HSStruct)); p->hs = h; p->port = 80; - IRCCreateThread(thread[2], thread_attr, scan_http_scan_port, p); + IRCCreateThread(thread[2], scan_http_scan_port, p); IRCMutexUnlock((h->lock)); IRCJoinThread(thread[0], NULL); IRCJoinThread(thread[1], NULL); @@ -176,6 +175,7 @@ void scan_http_scan(Scan_AddrStruct *h) IRCMutexLock((h->lock)); h->refcnt--; IRCMutexUnlock((h->lock)); + IRCDetachThread(IRCThreadSelf()); IRCExitThread(NULL); return; } @@ -240,8 +240,7 @@ void scan_http_scan_port(HSStruct *z) */ set_non_blocking(fd, NULL); if ((retval = connect(fd, (struct sockaddr *)&sin, - sizeof(sin))) == -1 && !((ERRNO == P_EWOULDBLOCK) - || (ERRNO == P_EINPROGRESS))) + sizeof(sin))) == -1 && !(ERRNO == P_EINPROGRESS)) { /* we have no socks server! */ CLOSE_SOCK(fd); @@ -261,7 +260,7 @@ void scan_http_scan_port(HSStruct *z) } bzero(httpbuf, sizeof(httpbuf)); - sprintf(httpbuf, "CONNECT %s:%i HTTP/1.1\n\n", + snprintf(httpbuf, sizeof httpbuf, "CONNECT %s:%i HTTP/1.1\n\n", Inet_ia2p(&xScan_endpoint->SIN_ADDR), ntohs(xScan_endpoint->SIN_PORT)); if ((retval = send(fd, httpbuf, strlen(httpbuf), 0)) != strlen(httpbuf)) { diff --git a/src/modules/scan_socks.c b/src/modules/scan_socks.c index c8b4a940b..168d803e6 100644 --- a/src/modules/scan_socks.c +++ b/src/modules/scan_socks.c @@ -143,18 +143,18 @@ int scan_socks_Unload(int module_unload) void scan_socks_scan(Scan_AddrStruct *h) { THREAD thread[2]; - THREAD_ATTR thread_attr; IRCMutexLock((h->lock)); h->refcnt++; - IRCCreateThread(thread[0], thread_attr, scan_socks4_scan, h); + IRCCreateThread(thread[0], scan_socks4_scan, h); h->refcnt++; - IRCCreateThread(thread[1], thread_attr, scan_socks5_scan, h); + IRCCreateThread(thread[1], scan_socks5_scan, h); IRCMutexUnlock((h->lock)); IRCJoinThread(thread[0], NULL); IRCJoinThread(thread[1], NULL); IRCMutexLock((h->lock)); h->refcnt--; IRCMutexUnlock((h->lock)); + IRCDetachThread(IRCThreadSelf()); IRCExitThread(NULL); return; } @@ -186,6 +186,13 @@ void scan_socks4_scan(Scan_AddrStruct *h) IRCMutexUnlock((h->lock)); /* IPv6 ?*/ #ifdef INET6 + IRCMutexLock((h->lock)); +#ifndef INET6 + sin.SIN_ADDR.S_ADDR = h->in.S_ADDR; +#else + bcopy(sin.SIN_ADDR.S_ADDR, h->in.S_ADDR, sizeof(h->in.S_ADDR)); +#endif + IRCMutexUnlock((h->lock)); /* ::ffff:ip hack */ cp = (u_char *)&h->in.s6_addr; if (!(cp[0] == 0 && cp[1] == 0 && cp[2] == 0 && cp[3] == 0 && cp[4] == 0 @@ -200,7 +207,6 @@ void scan_socks4_scan(Scan_AddrStruct *h) goto exituniverse; return; } - sin.SIN_PORT = htons((unsigned short)SCAN_ON_PORT); sin.SIN_FAMILY = AFINET; /* We do this non-blocking to prevent a hang of the entire ircd with newer @@ -222,14 +228,14 @@ void scan_socks4_scan(Scan_AddrStruct *h) */ set_non_blocking(fd, NULL); if ((retval = connect(fd, (struct sockaddr *)&sin, - sizeof(sin))) == -1 && !((ERRNO == P_EWOULDBLOCK) - || (ERRNO == P_EINPROGRESS))) + sizeof(sin))) == -1 && !(ERRNO == P_EINPROGRESS)) { /* we have no socks server! */ CLOSE_SOCK(fd); goto exituniverse; return; } +ircd_log(LOG_ERROR, "%s:%d - (Connection Established)", Inet_ia2p(&h->in), SCAN_ON_PORT); /* We wait for write-ready */ tv.tv_sec = xScan_TimeOut; @@ -293,6 +299,7 @@ exituniverse: IRCMutexLock((h->lock)); h->refcnt--; IRCMutexUnlock((h->lock)); + /* We get joined, we need no steekin Detach */ IRCExitThread(NULL); return; } @@ -359,8 +366,7 @@ void scan_socks5_scan(Scan_AddrStruct *h) set_non_blocking(fd, NULL); if ((retval = connect(fd, (struct sockaddr *)&sin, sizeof(sin))) == -1 && - !((ERRNO == P_EWOULDBLOCK) - || (ERRNO == P_EINPROGRESS))) + !(ERRNO == P_EINPROGRESS)) { /* we have no socks server! */ CLOSE_SOCK(fd); @@ -456,6 +462,7 @@ exituniverse: IRCMutexLock(h->lock); h->refcnt--; IRCMutexUnlock(h->lock); + /* We need no steekin detach */ IRCExitThread(NULL); return; } diff --git a/src/modules/web/httpd.c b/src/modules/web/httpd.c index 6acbc2c32..f1ffee2f3 100644 --- a/src/modules/web/httpd.c +++ b/src/modules/web/httpd.c @@ -159,9 +159,8 @@ int httpd_Unload(int module_unload) void httpd_setup_acceptthread(void) { THREAD thread; - THREAD_ATTR thread_attr; - IRCCreateThread(thread, thread_attr, httpd_acceptthread, NULL); + IRCCreateThread(thread, httpd_acceptthread, NULL); return; } @@ -172,7 +171,6 @@ void httpd_acceptthread(void *p) int retval; SOCKET callerfd = -1; THREAD thread; - THREAD_ATTR thread_attr; HTTPd_Request *req = NULL; tv.tv_sec = 10; @@ -190,7 +188,7 @@ void httpd_acceptthread(void *p) req = (HTTPd_Request *) MyMallocEx(sizeof(HTTPd_Request)); req->fd = callerfd; set_sock_opts(callerfd, NULL); - IRCCreateThread(thread, thread_attr, + IRCCreateThread(thread, httpd_socketthread, (void *)req); req = NULL; } @@ -282,6 +280,7 @@ void httpd_socketthread(void *preq) MyFree(hp2); } MyFree(request); + IRCDetachThread(IRCThreadSelf()); IRCExitThread(NULL); return; } @@ -385,8 +384,8 @@ void sockprintf(HTTPd_Request *r, char *format, ...) va_list ap; va_start(ap, format); - vsprintf(r->inbuf, format, ap); - strcat(r->inbuf, "\r\n"); + vsnprintf(r->inbuf, sizeof r->inbuf, format, ap); + strlcat(r->inbuf, "\r\n", sizeof(r->inbuf)); va_end(ap); set_blocking(r->fd); send(r->fd, r->inbuf, strlen(r->inbuf), 0), diff --git a/src/modules/web/phtml.c b/src/modules/web/phtml.c index 83ddb04cf..60f943c34 100644 --- a/src/modules/web/phtml.c +++ b/src/modules/web/phtml.c @@ -105,7 +105,7 @@ DLLFUNC int h_u_phtml(HTTPd_Request *r) { int section = 0; char buf[1024]; - char bbuf[1024]; + char bbuf[sizeof buf]; char *s; FILE *f = NULL; diff --git a/src/parse.c b/src/parse.c index 1cd54b489..66b83c6f7 100644 --- a/src/parse.c +++ b/src/parse.c @@ -161,7 +161,7 @@ void ban_flooder(aClient *cptr) NULL /*8 reason */ }; - strcpy(hostip, (char *)inetntoa((char *)&cptr->ip)); + strlcpy(hostip, (char *)inetntoa((char *)&cptr->ip), sizeof(hostip)); tkllayer[4] = hostip; tkllayer[5] = me.name; diff --git a/src/res.c b/src/res.c index 40c487913..5c0f0c6c0 100644 --- a/src/res.c +++ b/src/res.c @@ -187,7 +187,7 @@ static void rem_request(ResRQ *old) #ifdef _WIN32 while (old->locked) Sleep(0); - #endif +#endif for (rptr = &first; *rptr; r2ptr = *rptr, rptr = &(*rptr)->next) if (*rptr == old) { @@ -203,7 +203,7 @@ static void rem_request(ResRQ *old) r2ptr = old; #ifndef _WIN32 if (r2ptr->he.h_name) - MyFree((char *)r2ptr->he.h_name); + MyFree(r2ptr->he.h_name); for (i = 0; i < MAXALIASES; i++) if ((s = r2ptr->he.h_aliases[i])) MyFree(s); @@ -213,7 +213,7 @@ static void rem_request(ResRQ *old) #endif if (r2ptr->name) MyFree(r2ptr->name); - MyFree((char *)r2ptr); + MyFree(r2ptr); return; } @@ -731,7 +731,7 @@ static int proc_answer(ResRQ *rptr, HEADER *hptr, char *buf, char *eob) /* name server never returns with trailing '.' */ if (!index(hostbuf, '.') && (ircd_res.options & RES_DEFNAMES)) { - (void)strcat(hostbuf, dot); + (void)strlcat(hostbuf, dot, sizeof hostbuf); len++; (void)strncat(hostbuf, ircd_res.defdname, sizeof(hostbuf) - 1 - len); @@ -789,7 +789,7 @@ static int proc_answer(ResRQ *rptr, HEADER *hptr, char *buf, char *eob) if (!hp->h_name && len < HOSTLEN) { hp->h_name =(char *)MyMalloc(len+1); - (void)strcpy(hp->h_name, hostbuf); + (void)strlcpy(hp->h_name, hostbuf, len+1); } ans++; adr++; @@ -820,7 +820,7 @@ static int proc_answer(ResRQ *rptr, HEADER *hptr, char *buf, char *eob) else { hp->h_name = (char *)MyMalloc(len + 1); - (void)strcpy(hp->h_name, hostbuf); + (void)strlcpy(hp->h_name, hostbuf, len +1); } ans++; break; @@ -832,7 +832,7 @@ static int proc_answer(ResRQ *rptr, HEADER *hptr, char *buf, char *eob) if (alias >= &(hp->h_aliases[MAXALIASES - 1])) break; *alias = (char *)MyMalloc(len + 1); - (void)strcpy(*alias++, hostbuf); + (void)strlcpy(*alias++, hostbuf, len+1); *alias = NULL; ans++; break; @@ -1096,7 +1096,7 @@ struct hostent *get_res(char *lp,long id) long amt; struct hostent *hp, *he = rptr->he; - strcpy(tempname, he->h_name); + strlcpy(tempname, he->h_name, sizeof tempname); hp = gethostbyname(tempname); if (hp && !bcmp(hp->h_addr, he->h_addr, sizeof(struct IN_ADDR))) { @@ -1590,7 +1590,7 @@ static aCache *rem_list(aCache *cp) if (*cpp == cp) { *cpp = cp->list_next; - MyFree((char *)cp); + MyFree(cp); break; } return cr; @@ -1669,7 +1669,7 @@ static void rem_cache(aCache *ocp) break; } #ifdef _WIN32 - MyFree((char *)hp); + MyFree(hp); #else /* * free memory used to hold the various host names and the array @@ -1681,7 +1681,7 @@ static void rem_cache(aCache *ocp) { for (hashv = 0; hp->h_aliases[hashv]; hashv++) MyFree(hp->h_aliases[hashv]); - MyFree((char *)hp->h_aliases); + MyFree(hp->h_aliases); } /* @@ -1690,11 +1690,11 @@ static void rem_cache(aCache *ocp) if (hp->h_addr_list) { if (*hp->h_addr_list) - MyFree((char *)*hp->h_addr_list); - MyFree((char *)hp->h_addr_list); + MyFree(*hp->h_addr_list); + MyFree(hp->h_addr_list); } #endif - MyFree((char *)ocp); + MyFree(ocp); incache--; cainfo.ca_dels++; @@ -1911,6 +1911,9 @@ int res_copyhostent(struct hostent *from, struct hostent *to) */ amt = (long)to + sizeof(struct hostent); to->h_name = (char *)amt; + /* + * WIN32: FIXME: THIS LOOKS BAD + */ strcpy(to->h_name, from->h_name); amt += strlen(to->h_name)+1; /* Setup tto alias list */ diff --git a/src/res_init.c b/src/res_init.c index 8a0b1df84..2d49c3597 100644 --- a/src/res_init.c +++ b/src/res_init.c @@ -464,7 +464,7 @@ int ircd_res_init(void) if (ircd_res.defdname[0] == 0 && gethostname(buf, sizeof(ircd_res.defdname) - 1) == 0 && (cp = strchr(buf, '.')) != NULL) - strcpy(ircd_res.defdname, cp + 1); + strlcpy(ircd_res.defdname, cp + 1, sizeof ircd_res.defdname); /* find components of local domain that might be searched */ if (havesearch == 0) diff --git a/src/s_auth.c b/src/s_auth.c index 0534cb6c5..81fcbe0f9 100644 --- a/src/s_auth.c +++ b/src/s_auth.c @@ -100,8 +100,7 @@ void start_auth(aClient *cptr) sock.SIN_FAMILY = AFINET; if (connect(cptr->authfd, (struct sockaddr *)&sock, - sizeof(sock)) == -1 && !((ERRNO == P_EWOULDBLOCK) - || (ERRNO == P_EINPROGRESS))) + sizeof(sock)) == -1 && !(ERRNO == P_EINPROGRESS)) { ircstp->is_abad++; /* diff --git a/src/s_bsd.c b/src/s_bsd.c index 1bed0a2a7..968d0ad04 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -106,7 +106,7 @@ static struct SOCKADDR_IN mysk; static struct SOCKADDR *connect_inet(ConfigItem_link *, aClient *, int *); static int completed_connection(aClient *); -static int check_init(aClient *, char *); +static int check_init(aClient *, char *, size_t); #ifndef _WIN32 static void do_dns_async(); void set_sock_opts(int, aClient *); @@ -354,7 +354,7 @@ int inetport(aClient *cptr, char *name, int port) { (void)ircsprintf(cptr->sockhost, "%-.42s.%.u", name, (unsigned int)port); - (void)strcpy(cptr->name, me.name); + (void)strlcpy(cptr->name, me.name, sizeof cptr->name); } /* * At first, open a new socket @@ -407,7 +407,7 @@ int inetport(aClient *cptr, char *name, int port) { ircsprintf(backupbuf, "Error binding stream socket to IP %s port %i", ipname, port); - strcat(backupbuf, "- %s:%s"); + strlcat(backupbuf, "- %s:%s", sizeof backupbuf); report_error(backupbuf, cptr); CLOSE_SOCK(cptr->fd); cptr->fd = -1; @@ -647,7 +647,7 @@ void write_pidfile(void) * from either the server's sockhost (if client fd is a tty or localhost) * or from the ip# converted into a string. 0 = success, -1 = fail. */ -static int check_init(aClient *cptr, char *sockn) +static int check_init(aClient *cptr, char *sockn, size_t size) { struct SOCKADDR_IN sk; int len = sizeof(struct SOCKADDR_IN); @@ -668,7 +668,7 @@ static int check_init(aClient *cptr, char *sockn) report_error("connect failure: %s %s", cptr); return -1; } - (void)strcpy(sockn, (char *)Inet_si2p(&sk)); + (void)strlcpy(sockn, (char *)Inet_si2p(&sk), size); #ifdef INET6 if (IN6_IS_ADDR_LOOPBACK(&sk.SIN_ADDR)) @@ -703,7 +703,7 @@ int check_client(aClient *cptr) Debug((DEBUG_DNS, "ch_cl: check access for %s[%s]", cptr->name, inetntoa((char *)&cptr->ip))); - if (check_init(cptr, sockname)) + if (check_init(cptr, sockname, sizeof(sockname))) return -2; hp = cptr->hostp; @@ -2295,7 +2295,7 @@ int connect_server(ConfigItem_link *aconf, aClient *by, struct hostent *hp) cptr->serv->conf = aconf; if (by && IsPerson(by)) { - (void)strcpy(cptr->serv->by, by->name); + (void)strlcpy(cptr->serv->by, by->name, sizeof cptr->serv->by); if (cptr->serv->user) free_user(cptr->serv->user, NULL); cptr->serv->user = by->user; @@ -2303,7 +2303,7 @@ int connect_server(ConfigItem_link *aconf, aClient *by, struct hostent *hp) } else { - (void)strcpy(cptr->serv->by, "AutoConn."); + (void)strlcpy(cptr->serv->by, "AutoConn.", sizeof cptr->serv->by); if (cptr->serv->user) free_user(cptr->serv->user, NULL); cptr->serv->user = NULL; diff --git a/src/s_conf.c b/src/s_conf.c index 67a823276..713171f45 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -692,9 +692,9 @@ static ConfigFile *config_parse(char *filename, char *confdata) if (curce) config_error("%s: Unexpected EOF for variable starting at %i\n", filename, curce->ce_varlinenum); - else if (cursection) + else if (cursection) config_error("%s: Unexpected EOF for section starting at %i\n", - filename, curce->ce_sectlinenum); + filename, cursection->ce_sectlinenum); else config_error("%s: Unexpected EOF.\n", filename); config_entry_free(curce); @@ -3695,7 +3695,8 @@ int rehash(aClient *cptr, aClient *sptr, int sig) listen_cleanup(); close_listeners(); run_configuration(); - check_pings(TStime(), 1); + loop.do_bancheck = 1; + /* Check pings is done AFTERWARDS return anyhow, fuckheads. */ sendto_realops("Completed rehash"); return 0; } @@ -3857,7 +3858,7 @@ ConfigItem_ban *Find_ban(char *host, short type) if (ban->flag.type == type) if (!match(ban->mask, host)) { /* Person got a exception */ - if (Find_except(host, type)) + if (type == CONF_BAN_USER && Find_except(host, CONF_EXCEPT_BAN)) return NULL; return ban; } @@ -3925,11 +3926,21 @@ int AllowClient(aClient *cptr, struct hostent *hp, char *sockhost) sockhost, fullname)); if (index(aconf->hostname, '@')) { + /* + * Doing strlcpy / strlcat here + * would simply be a waste. We are + * ALREADY sure that it is proper + * lengths + */ (void)strcpy(uhost, cptr->username); (void)strcat(uhost, "@"); } else *uhost = '\0'; + /* + * Same here as above + * -Stskeeps + */ (void)strncat(uhost, fullname, sizeof(uhost) - strlen(uhost)); if (!match(aconf->hostname, uhost)) diff --git a/src/s_extra.c b/src/s_extra.c index 82700a6b5..23c618e41 100644 --- a/src/s_extra.c +++ b/src/s_extra.c @@ -365,8 +365,8 @@ int m_vhost(aClient *cptr, aClient *sptr, int parc, char *parv[]) me.name, sptr->name, user); return 0; } - strcpy(host, make_user_host(sptr->user->username, sptr->user->realhost)); - strcpy(host2, make_user_host(sptr->user->username, (char *)Inet_ia2p(&sptr->ip))); + strlcpy(host, make_user_host(sptr->user->username, sptr->user->realhost), sizeof host); + strlcpy(host2, make_user_host(sptr->user->username, (char *)Inet_ia2p(&sptr->ip)), sizeof host2); for (from = (ConfigItem_oper_from *)vhost->from; from; from = (ConfigItem_oper_from *)from->next) { if (!match(from->name, host) || !match(from->name, host2)) break; @@ -392,10 +392,10 @@ int m_vhost(aClient *cptr, aClient *sptr, int parc, char *parv[]) len = strlen(vhost->virthost); length = len > HOSTLEN ? HOSTLEN : len; sptr->user->virthost = MyMalloc(length + 1); - strncpy(sptr->user->virthost, vhost->virthost, length + 1); + strlcpy(sptr->user->virthost, vhost->virthost, length + 1); if (vhost->virtuser) { strcpy(olduser, sptr->user->username); - strncpy(sptr->user->username, vhost->virtuser, USERLEN); + strlcpy(sptr->user->username, vhost->virtuser, USERLEN); } sptr->umodes |= UMODE_HIDE; sptr->umodes |= UMODE_SETHOST; @@ -441,10 +441,11 @@ void ircd_log(int flags, char *format, ...) char buf[2048], timebuf[128]; int fd; struct stat fstats; + va_start(ap, format); ircvsprintf(buf, format, ap); - strcat(buf, "\n"); - sprintf(timebuf, "[%s] - ", myctime(TStime())); + strlcat(buf, "\n", sizeof buf); + snprintf(timebuf, sizeof timebuf, "[%s] - ", myctime(TStime())); for (logs = conf_log; logs; logs = (ConfigItem_log *) logs->next) { #ifdef HAVE_SYSLOG if (!stricmp(logs->file, "syslog") && logs->flags & flags) { diff --git a/src/s_kline.c b/src/s_kline.c index df76cfd6a..34a57d8ee 100644 --- a/src/s_kline.c +++ b/src/s_kline.c @@ -46,7 +46,7 @@ aTKline *tklines = NULL; #define AllocCpy(x,y) x = (char *) MyMalloc(strlen(y) + 1); strcpy(x,y) #define GFreeStr(x) MyFree((char *) x) #define GFreeGline(x) MyFree((aGline *) x) -extern char zlinebuf[]; +extern char zlinebuf[BUFSIZE]; /* @@ -124,27 +124,27 @@ aTKline *tkl_expire(aTKline * tmp) { if (tmp->type & TKL_KILL) { - strcpy(whattype, "G:Line"); + strlcpy(whattype, "G:Line", sizeof whattype); } else if (tmp->type & TKL_ZAP) { - strcpy(whattype, "Global Z:Line"); + strlcpy(whattype, "Global Z:Line", sizeof whattype); } else if (tmp->type & TKL_SHUN) - strcpy(whattype, "Shun"); + strlcpy(whattype, "Shun", sizeof whattype); } else { if (tmp->type & TKL_KILL) { - strcpy(whattype, "Timed K:Line"); + strlcpy(whattype, "Timed K:Line", sizeof whattype); } else if (tmp->type & TKL_ZAP) { - strcpy(whattype, "Timed Z:Line"); + strlcpy(whattype, "Timed Z:Line", sizeof whattype); } else if (tmp->type & TKL_SHUN) - strcpy(whattype, "Local Shun"); + strlcpy(whattype, "Local Shun", sizeof whattype); } sendto_snomask(SNO_TKL, "*** Expiring %s (%s@%s) made by %s (Reason: %s) set %li seconds ago", @@ -227,8 +227,8 @@ EVENT(tkl_check_expire) /* - returns -1 if no tkline found - returns >= 0 if client exits + returns <0 if client exists (banned) + returns 1 if it is excepted */ int find_tkline_match(aClient *cptr, int xx) @@ -265,14 +265,14 @@ int find_tkline_match(aClient *cptr, int xx) } if (points != 1) - return -1; + return 1; strcpy(host, make_user_host(cname, chost)); strcpy(host2, make_user_host(cname, cip)); for (excepts = conf_except; excepts; excepts = (ConfigItem_except *)excepts->next) { if (excepts->flag.type != CONF_EXCEPT_TKL || excepts->type != lp->type) continue; if (!match(excepts->mask, host) || !match(excepts->mask, host2)) - return -1; + return 1; } if ((lp->type & TKL_KILL) && (xx != 2)) @@ -317,14 +317,14 @@ int find_tkline_match(aClient *cptr, int xx) if (lp->type & (TKL_SHUN)) { if (IsShunned(cptr)) - return -1; + return 1; if (IsAdmin(cptr)) - return -1; + return 1; SetShunned(cptr); - return -1; + return 2; } - return -1; + return 3; } int find_tkline_match_zap(aClient *cptr) @@ -363,7 +363,7 @@ int find_tkline_match_zap(aClient *cptr) inet_ntop(AF_INET6, (char *)&cptr->ip, mydummy, MYDUMMY_SIZE)); #endif - strcpy(zlinebuf, msge); + strlcpy(zlinebuf, msge, sizeof zlinebuf); return (1); } } @@ -372,22 +372,6 @@ int find_tkline_match_zap(aClient *cptr) } -int tkl_sweep(void) -{ - /* just sweeps local for people that should be killed */ - aClient *acptr; - long i; - - tkl_check_expire(NULL); - for (i = 0; i <= (MAXCONNECTIONS - 1); i++) - { - if ((acptr = local[i])) - find_tkline_match(acptr, 0); - } - return 1; -} - - void tkl_stats(aClient *cptr) { aTKline *tk; @@ -597,7 +581,8 @@ int m_tkl(aClient *cptr, aClient *sptr, int parc, char *parv[]) (LOG_TKL, "Permanent %s added for %s@%s on %s GMT (from %s: %s)", txt, parv[3], parv[4], gmt, parv[5], parv[8]); } - loop.do_tkl_sweep = 1; + loop.do_bancheck = 1; + /* Makes check_pings be run ^^ */ if (type & TKL_GLOBAL) { sendto_serv_butone(cptr, diff --git a/src/s_misc.c b/src/s_misc.c index f19ddde48..034be349a 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -222,7 +222,7 @@ char *myctime(time_t value) static char buf[28]; char *p; - (void)strcpy(buf, ctime(&value)); + (void)strlcpy(buf, ctime(&value), sizeof buf); if ((p = (char *)index(buf, '\n')) != NULL) *p = '\0'; @@ -431,7 +431,7 @@ int exit_client(aClient *cptr, aClient *sptr, aClient *from, char *comment) sendto_conn_hcn ("*** Notice -- Client exiting: %s (%s@%s) [%s] [%s]", sptr->name, sptr->user->username, - sptr->user->realhost, comment, sptr->sockhost); + sptr->user->realhost, comment, inet_ntoa(sptr->ip)); /* Clean out list and watch structures -Donwulff */ hash_del_watch_list(sptr); @@ -490,6 +490,11 @@ int exit_client(aClient *cptr, aClient *sptr, aClient *from, char *comment) */ if (cptr && !recurse) { + /* + * We are sure as we RELY on sptr->srvptr->name and + * sptr->name to be less or equal to HOSTLEN + * Waste of strlcpy/strlcat here + */ (void)strcpy(comment1, sptr->srvptr->name); (void)strcat(comment1, " "); (void)strcat(comment1, sptr->name); diff --git a/src/s_numeric.c b/src/s_numeric.c index 3025a8671..435b5a2ea 100644 --- a/src/s_numeric.c +++ b/src/s_numeric.c @@ -74,6 +74,9 @@ int do_numeric(int numeric, aClient *cptr, aClient *sptr, int parc, char *parv[ buffer[0] = '\0'; if (parc > 2) { + /* + * For strlcat nazis, please read above + */ for (i = 2; i < (parc - 1); i++) { (void)strcat(buffer, " "); diff --git a/src/s_serv.c b/src/s_serv.c index 9cbfe10e0..cce6490e5 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -1729,7 +1729,7 @@ CMD_FUNC(m_watch) continue; } *buf = '\0'; - strcpy(buf, lp->value.wptr->nick); + strlcpy(buf, lp->value.wptr->nick, sizeof buf); count = strlen(parv[0]) + strlen(me.name) + 10 + strlen(buf); @@ -1851,6 +1851,11 @@ char *get_client_name2(aClient *acptr, int showports) return pointer; if (!strrchr(pointer, '.')) return NULL; + /* + * This may seem like wack but remind this is only used + * in rows of get_client_name2's, so it's perfectly fair + * + */ strcpy((char *)strrchr((char *)pointer, '.'), ".0]"); return pointer; @@ -2243,7 +2248,7 @@ CMD_FUNC(m_stats) for (bans = conf_ban; bans; bans = (ConfigItem_ban *)bans->next) { if (bans->flag.type == CONF_BAN_NICK && (bans->flag.type2 == CONF_BAN_TYPE_AKILL)) sendto_one(sptr, rpl_str(RPL_SQLINE_NICK), - me.name, parv[0], bans->mask, bans->reason); + me.name, parv[0], bans->mask, bans->reason ? bans->reason : "No Reason"); } break; } @@ -2443,9 +2448,9 @@ CMD_FUNC(m_stats) sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, parv[0], "S - Send the dynamic configuration list"); sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, parv[0], - "T - Send the tld block list"); + "t - Send the tld block list"); sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, parv[0], - "t - Send connection information"); + "T - Send connection information"); sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, parv[0], "u - Send server uptime and connection count"); sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, parv[0], @@ -3733,7 +3738,7 @@ HUNTED_ISME) goto playmotd; } #endif - strcpy(userhost,make_user_host(cptr->user->username, cptr->user->realhost)); + strlcpy(userhost,make_user_host(cptr->user->username, cptr->user->realhost), sizeof userhost); for (ptr = conf_tld; ptr; ptr = (ConfigItem_tld *) ptr->next) { if (!match(ptr->mask, userhost)) @@ -4025,7 +4030,7 @@ CMD_FUNC(m_rules) goto playrules; } #endif - strcpy(userhost,make_user_host(cptr->user->username, cptr->user->realhost)); + strlcpy(userhost,make_user_host(cptr->user->username, cptr->user->realhost), sizeof userhost); for (ptr = conf_tld; ptr; ptr = (ConfigItem_tld *) ptr->next) { if (!match(ptr->mask, userhost)) diff --git a/src/s_svs.c b/src/s_svs.c index d0d1d7560..ab892f696 100644 --- a/src/s_svs.c +++ b/src/s_svs.c @@ -125,7 +125,7 @@ int advanced_check(char *userhost, int ipstat) char *ipseg[10 + 2]; char safebuffer[512] = ""; /* buffer strtoken() can mess up to its heart's content...;> */ - strcpy(safebuffer, userhost); + strlcpy(safebuffer, userhost, sizeof safebuffer); #define userhost safebuffer #define IP_WILDS_OK(x) ((x)<2? 0 : 1) @@ -272,7 +272,7 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { char *current = malloc(strlen(parv[1])+1); char *xparv[3]; bzero(current, strlen(parv[1])+1); - bzero(output, 501); + bzero(output, sizeof output); while(format->parameters[i] && j < 500) { k = 0; if (format->parameters[i] == '%') { @@ -295,7 +295,7 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { continue; if (j + strlen(current)+1 >= 500) break; - strcat(output, current); + strlcat(output, current, sizeof output); j += strlen(current); } diff --git a/src/s_user.c b/src/s_user.c index 12bfb7bbd..cf372702d 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -394,7 +394,7 @@ int hunt_server_token(aClient *cptr, aClient *sptr, char *command, char *token, } if (acptr) { - char buff[512]; + char buff[1024]; if (IsMe(acptr) || MyClient(acptr)) return HUNTED_ISME; if (match(acptr->name, parv[server])) @@ -887,7 +887,7 @@ extern int register_user(aClient *cptr, aClient *sptr, char *nick, char *usernam "Your GECOS (real name) is banned from this server"); } tkl_check_expire(NULL); - if ((xx = find_tkline_match(sptr, 0)) != -1) + if ((xx = find_tkline_match(sptr, 0)) < 0) { ircstp->is_ref++; return xx; @@ -2398,6 +2398,11 @@ CMD_FUNC(m_umode) IRCstats.operators++; if ((setflags & UMODE_OPER) && !IsOper(sptr)) IRCstats.operators--; + /* FIXME: This breaks something */ + if (!(setflags & UMODE_HIDEOPER) && IsHideOper(sptr)) + IRCstats.operators--; + if ((setflags & UMODE_HIDEOPER) && !IsHideOper(sptr)) + IRCstats.operators++; if (!(setflags & UMODE_INVISIBLE) && IsInvisible(sptr)) IRCstats.invisible++; if ((setflags & UMODE_INVISIBLE) && !IsInvisible(sptr)) diff --git a/src/send.c b/src/send.c index cb6bd21a0..04c6e5b0b 100644 --- a/src/send.c +++ b/src/send.c @@ -1659,12 +1659,12 @@ void sendto_connectnotice(char *nick, anUser *user, aClient *sptr) #endif ircsprintf(connecth, "*** Notice -- Client connecting: %s (%s@%s) [%s] {%s}", nick, - user->username, user->realhost, sptr->sockhost, + user->username, user->realhost, inet_ntoa(sptr->ip), sptr->class ? sptr->class->name : "0"); for (i = 0; i <= LastSlot; i++) if ((cptr = local[i]) && !IsServer(cptr) && !IsMe(cptr) && - IsOper(cptr) && (cptr->user->snomask & SNO_CLIENT)) + IsAnOper(cptr) && (cptr->user->snomask & SNO_CLIENT)) { if (IsHybNotice(cptr)) sendto_one(cptr, ":%s NOTICE %s :%s", me.name, diff --git a/src/ssl.rnd b/src/ssl.rnd index 253c20302..bca937cc8 100644 Binary files a/src/ssl.rnd and b/src/ssl.rnd differ diff --git a/src/support.c b/src/support.c index adc5349ab..8189259ee 100644 --- a/src/support.c +++ b/src/support.c @@ -437,6 +437,771 @@ void iCstrip(char *line) *c = '\0'; } +/* + * from ircd-hybrid-7beta14 + * (C) respective coders +*/ +/************************************************************** + * Original header, taken from mutt...: + * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 + * A bombproof version of doprnt (dopr) included. + * Sigh. This sort of thing is always nasty do deal with. Note that + * the version here does not include floating point... + * + * snprintf() is used instead of sprintf() as it does limit checks + * for string length. This covers a nasty loophole. + * + * The other functions are there to prevent NULL pointers from + * causing nast effects. + * + * More Recently: + * Brandon Long 9/15/96 for mutt 0.43 + * This was ugly. It is still ugly. I opted out of floating point + * numbers, but the formatter understands just about everything + * from the normal C string format, at least as far as I can tell from + * the Solaris 2.5 printf(3S) man page. + * + * Brandon Long 10/22/97 for mutt 0.87.1 + * Ok, added some minimal floating point support, which means this + * probably requires libm on most operating systems. Don't yet + * support the exponent (e,E) and sigfig (g,G). Also, fmtint() + * was pretty badly broken, it just wasn't being exercised in ways + * which showed it, so that's been fixed. Also, formated the code + * to mutt conventions, and removed dead code left over from the + * original. Also, there is now a builtin-test, just compile with: + * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm + * and run snprintf for results. + * + * Thomas Roessler 01/27/98 for mutt 0.89i + * The PGP code was using unsigned hexadecimal formats. + * Unfortunately, unsigned formats simply didn't work. + * + * Michael Elkins 03/05/98 for mutt 0.90.8 + * The original code assumed that both snprintf() and vsnprintf() were + * missing. Some systems only have snprintf() but not vsnprintf(), so + * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. + * + **************************************************************/ + +#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) + +/* varargs declarations: */ + +# define HAVE_STDARGS /* let's hope that works everywhere (mj) */ +# define VA_LOCAL_DECL va_list ap +# define VA_START(f) va_start(ap, f) +# define VA_SHIFT(v,t) ; /* no-op for ANSI */ +# define VA_END va_end(ap) + + +static void dopr (char *buffer, size_t maxlen, const char *format, + va_list args); +static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max); +static void fmtint (char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags); +static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, + long double fvalue, int min, int max, int flags); +static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); + +/* + * dopr(): poor man's version of doprintf + */ + +/* format read states */ +#define DP_S_DEFAULT 0 +#define DP_S_FLAGS 1 +#define DP_S_MIN 2 +#define DP_S_DOT 3 +#define DP_S_MAX 4 +#define DP_S_MOD 5 +#define DP_S_CONV 6 +#define DP_S_DONE 7 + +/* format flags - Bits */ +#define DP_F_MINUS (1 << 0) +#define DP_F_PLUS (1 << 1) +#define DP_F_SPACE (1 << 2) +#define DP_F_NUM (1 << 3) +#define DP_F_ZERO (1 << 4) +#define DP_F_UP (1 << 5) +#define DP_F_UNSIGNED (1 << 6) + +/* Conversion Flags */ +#define DP_C_SHORT 1 +#define DP_C_LONG 2 +#define DP_C_LDOUBLE 3 + +#define char_to_int(p) (p - '0') +#undef MAX +#define MAX(p,q) ((p >= q) ? p : q) + +static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) +{ + char ch; + long value; + long double fvalue; + char *strvalue; + int min; + int max; + int state; + int flags; + int cflags; + size_t currlen; + + state = DP_S_DEFAULT; + currlen = flags = cflags = min = 0; + max = -1; + ch = *format++; + + while (state != DP_S_DONE) + { + if ((ch == '\0') || (currlen >= maxlen)) + state = DP_S_DONE; + + switch(state) + { + case DP_S_DEFAULT: + if (ch == '%') + state = DP_S_FLAGS; + else + dopr_outch (buffer, &currlen, maxlen, ch); + ch = *format++; + break; + case DP_S_FLAGS: + switch (ch) + { + case '-': + flags |= DP_F_MINUS; + ch = *format++; + break; + case '+': + flags |= DP_F_PLUS; + ch = *format++; + break; + case ' ': + flags |= DP_F_SPACE; + ch = *format++; + break; + case '#': + flags |= DP_F_NUM; + ch = *format++; + break; + case '0': + flags |= DP_F_ZERO; + ch = *format++; + break; + default: + state = DP_S_MIN; + break; + } + break; + case DP_S_MIN: + if (isdigit((unsigned char)ch)) + { + min = 10*min + char_to_int (ch); + ch = *format++; + } + else if (ch == '*') + { + min = va_arg (args, int); + ch = *format++; + state = DP_S_DOT; + } + else + state = DP_S_DOT; + break; + case DP_S_DOT: + if (ch == '.') + { + state = DP_S_MAX; + ch = *format++; + } + else + state = DP_S_MOD; + break; + case DP_S_MAX: + if (isdigit((unsigned char)ch)) + { + if (max < 0) + max = 0; + max = 10*max + char_to_int (ch); + ch = *format++; + } + else if (ch == '*') + { + max = va_arg (args, int); + ch = *format++; + state = DP_S_MOD; + } + else + state = DP_S_MOD; + break; + case DP_S_MOD: + /* Currently, we don't support Long Long, bummer */ + switch (ch) + { + case 'h': + cflags = DP_C_SHORT; + ch = *format++; + break; + case 'l': + cflags = DP_C_LONG; + ch = *format++; + break; + case 'L': + cflags = DP_C_LDOUBLE; + ch = *format++; + break; + default: + break; + } + state = DP_S_CONV; + break; + case DP_S_CONV: + switch (ch) + { + case 'd': + case 'i': + if (cflags == DP_C_SHORT) + value = va_arg (args, int); + else if (cflags == DP_C_LONG) + value = va_arg (args, long int); + else + value = va_arg (args, int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'o': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, int); + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else + value = va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); + break; + case 'u': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, int); + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else + value = va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'X': + flags |= DP_F_UP; + case 'x': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, int); + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else + value = va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); + break; + case 'f': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, long double); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'E': + flags |= DP_F_UP; + case 'e': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, long double); + else + fvalue = va_arg (args, double); + break; + case 'G': + flags |= DP_F_UP; + case 'g': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, long double); + else + fvalue = va_arg (args, double); + break; + case 'c': + dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + break; + case 's': + strvalue = va_arg (args, char *); + if (max < 0) + max = maxlen; /* ie, no max */ + fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); + break; + case 'p': + strvalue = va_arg (args, void *); + fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); + break; + case 'n': + if (cflags == DP_C_SHORT) + { + short int *num; + num = va_arg (args, short int *); + *num = currlen; + } + else if (cflags == DP_C_LONG) + { + long int *num; + num = va_arg (args, long int *); + *num = currlen; + } + else + { + int *num; + num = va_arg (args, int *); + *num = currlen; + } + break; + case '%': + dopr_outch (buffer, &currlen, maxlen, ch); + break; + case 'w': + /* not supported yet, treat as next char */ + ch = *format++; + break; + default: + /* Unknown, skip */ + break; + } + ch = *format++; + state = DP_S_DEFAULT; + flags = cflags = min = 0; + max = -1; + break; + case DP_S_DONE: + break; + default: + /* hmm? */ + break; /* some picky compilers need this */ + } + } + if (currlen < maxlen - 1) + buffer[currlen] = '\0'; + else + buffer[maxlen - 1] = '\0'; +} + +static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max) +{ + int padlen, strln; /* amount to pad */ + int cnt = 0; + + if (value == 0) + { + value = ""; + } + + for (strln = 0; value[strln]; ++strln); /* strlen */ + padlen = min - strln; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justify */ + + while ((padlen > 0) && (cnt < max)) + { + dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + ++cnt; + } + while (*value && (cnt < max)) + { + dopr_outch (buffer, currlen, maxlen, *value++); + ++cnt; + } + while ((padlen < 0) && (cnt < max)) + { + dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + ++cnt; + } +} + +/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ + +static void fmtint (char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags) +{ + int signvalue = 0; + unsigned long uvalue; + char convert[20]; + int place = 0; + int spadlen = 0; /* amount to space pad */ + int zpadlen = 0; /* amount to zero pad */ + int caps = 0; + + if (max < 0) + max = 0; + + uvalue = value; + + if(!(flags & DP_F_UNSIGNED)) + { + if( value < 0 ) { + signvalue = '-'; + uvalue = -value; + } + else + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else + if (flags & DP_F_SPACE) + signvalue = ' '; + } + + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ + + do { + convert[place++] = + (caps? "0123456789ABCDEF":"0123456789abcdef") + [uvalue % (unsigned)base ]; + uvalue = (uvalue / (unsigned)base ); + } while(uvalue && (place < 20)); + if (place == 20) place--; + convert[place] = 0; + + zpadlen = max - place; + spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); + if (zpadlen < 0) zpadlen = 0; + if (spadlen < 0) spadlen = 0; + if (flags & DP_F_ZERO) + { + zpadlen = MAX(zpadlen, spadlen); + spadlen = 0; + } + if (flags & DP_F_MINUS) + spadlen = -spadlen; /* Left Justifty */ + +#ifdef DEBUG_SNPRINTF + dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", + zpadlen, spadlen, min, max, place)); +#endif + + /* Spaces */ + while (spadlen > 0) + { + dopr_outch (buffer, currlen, maxlen, ' '); + --spadlen; + } + + /* Sign */ + if (signvalue) + dopr_outch (buffer, currlen, maxlen, signvalue); + + /* Zeros */ + if (zpadlen > 0) + { + while (zpadlen > 0) + { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + } + + /* Digits */ + while (place > 0) + dopr_outch (buffer, currlen, maxlen, convert[--place]); + + /* Left Justified spaces */ + while (spadlen < 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++spadlen; + } +} + +static long double abs_val (long double value) +{ + long double result = value; + + if (value < 0) + result = -value; + + return result; +} + +static long double pow10 (int exp) +{ + long double result = 1; + + while (exp) + { + result *= 10; + exp--; + } + + return result; +} + +static long round (long double value) +{ + long intpart; + + intpart = value; + value = value - intpart; + if (value >= 0.5) + intpart++; + + return intpart; +} + +static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, + long double fvalue, int min, int max, int flags) +{ + int signvalue = 0; + long double ufvalue; + char iconvert[20]; + char fconvert[20]; + int iplace = 0; + int fplace = 0; + int padlen = 0; /* amount to pad */ + int zpadlen = 0; + int caps = 0; + long intpart; + long fracpart; + + /* + * AIX manpage says the default is 0, but Solaris says the default + * is 6, and sprintf on AIX defaults to 6 + */ + if (max < 0) + max = 6; + + ufvalue = abs_val (fvalue); + + if (fvalue < 0) + signvalue = '-'; + else + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else + if (flags & DP_F_SPACE) + signvalue = ' '; + + intpart = ufvalue; + + /* + * Sorry, we only support 9 digits past the decimal because of our + * conversion method + */ + if (max > 9) + max = 9; + + /* We "cheat" by converting the fractional part to integer by + * multiplying by a factor of 10 + */ + fracpart = round ((pow10 (max)) * (ufvalue - intpart)); + + if (fracpart >= pow10 (max)) + { + intpart++; + fracpart -= pow10 (max); + } + +#ifdef DEBUG_SNPRINTF + dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart)); +#endif + + /* Convert integer part */ + do { + iconvert[iplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10]; + intpart = (intpart / 10); + } while(intpart && (iplace < 20)); + if (iplace == 20) iplace--; + iconvert[iplace] = 0; + + /* Convert fractional part */ + do { + fconvert[fplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; + fracpart = (fracpart / 10); + } while(fracpart && (fplace < 20)); + if (fplace == 20) fplace--; + fconvert[fplace] = 0; + + /* -1 for decimal point, another -1 if we are printing a sign */ + padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); + zpadlen = max - fplace; + if (zpadlen < 0) + zpadlen = 0; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justifty */ + + if ((flags & DP_F_ZERO) && (padlen > 0)) + { + if (signvalue) + { + dopr_outch (buffer, currlen, maxlen, signvalue); + --padlen; + signvalue = 0; + } + while (padlen > 0) + { + dopr_outch (buffer, currlen, maxlen, '0'); + --padlen; + } + } + while (padlen > 0) + { + dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + } + if (signvalue) + dopr_outch (buffer, currlen, maxlen, signvalue); + + while (iplace > 0) + dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); + + /* + * Decimal point. This should probably use locale to find the correct + * char to print out. + */ + dopr_outch (buffer, currlen, maxlen, '.'); + + while (fplace > 0) + dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); + + while (zpadlen > 0) + { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + + while (padlen < 0) + { + dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + } +} + +static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) +{ + if (*currlen < maxlen) + buffer[(*currlen)++] = c; +} +#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */ + +#ifndef HAVE_VSNPRINTF +int vsnprintf (char *str, size_t count, const char *fmt, va_list args) +{ + str[0] = 0; + dopr(str, count, fmt, args); + return(strlen(str)); +} +#endif /* !HAVE_VSNPRINTF */ + +#ifndef HAVE_SNPRINTF +/* VARARGS3 */ +#ifdef HAVE_STDARGS +int snprintf (char *str,size_t count,const char *fmt,...) +#else +int snprintf (va_alist) va_dcl +#endif +{ +#ifndef HAVE_STDARGS + char *str; + size_t count; + char *fmt; +#endif + VA_LOCAL_DECL; + + VA_START (fmt); + VA_SHIFT (str, char *); + VA_SHIFT (count, size_t ); + VA_SHIFT (fmt, char *); + (void) vsnprintf(str, count, fmt, ap); + VA_END; + return(strlen(str)); +} + +#ifdef TEST_SNPRINTF +#ifndef LONG_STRING +#define LONG_STRING 1024 +#endif +int main (void) +{ + char buf1[LONG_STRING]; + char buf2[LONG_STRING]; + char *fp_fmt[] = { + "%-1.5f", + "%1.5f", + "%123.9f", + "%10.5f", + "% 10.5f", + "%+22.9f", + "%+4.9f", + "%01.3f", + "%4f", + "%3.1f", + "%3.2f", + NULL + }; + double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, + 0.9996, 1.996, 4.136, 0}; + char *int_fmt[] = { + "%-1.5d", + "%1.5d", + "%123.9d", + "%5.5d", + "%10.5d", + "% 10.5d", + "%+22.33d", + "%01.3d", + "%4d", + NULL + }; + long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; + int x, y; + int fail = 0; + int num = 0; + + printf ("Testing snprintf format codes against system sprintf...\n"); + + for (x = 0; fp_fmt[x] != NULL ; x++) + for (y = 0; fp_nums[y] != 0 ; y++) + { + snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]); + sprintf (buf2, fp_fmt[x], fp_nums[y]); + if (strcmp (buf1, buf2)) + { + printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", /* __SPRINTF_CHECKED__ */ + fp_fmt[x], buf1, buf2); + fail++; + } + num++; + } + + for (x = 0; int_fmt[x] != NULL ; x++) + for (y = 0; int_nums[y] != 0 ; y++) + { + snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]); + sprintf (buf2, int_fmt[x], int_nums[y]); + if (strcmp (buf1, buf2)) + { + printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", /* __SPRINTF_CHECKED__ */ + int_fmt[x], buf1, buf2); + fail++; + } + num++; + } + printf ("%d tests failed out of %d.\n", fail, num); +} +#endif /* SNPRINTF_TEST */ + +#endif /* !HAVE_SNPRINTF */ + + /* * Copyright 1996, 1997, 1998, 1999, 2000 Michiel Boland. * Under the BSD license (without advertising clause) @@ -585,6 +1350,82 @@ time_t rfc2time(char *s) day + daytab[year % 4 == 0][mon] + 365L * (year - 1970L) + ((year - 1969L) >> 2)))); } +#ifndef HAVE_STRLCPY +/* + * bsd'sh strlcpy(). + * The strlcpy() function copies up to size-1 characters from the + * NUL-terminated string src to dst, NUL-terminating the result. + * Return: total length of the string tried to create. + */ +size_t +strlcpy(char *dst, const char *src, size_t size) +{ + size_t len = strlen(src); + size_t ret = len; + + if (size <= 0) + return 0; + if (len >= size) + len = size - 1; + memcpy(dst, src, len); + dst[len] = 0; + + return ret; +} +#endif + +#ifndef HAVE_STRLCAT +/* + * bsd'sh strlcat(). + * The strlcat() function appends the NUL-terminated string src to the end of + * dst. It will append at most size - strlen(dst) - 1 bytes, NUL-terminating + * the result. + */ +size_t +strlcat(char *dst, const char *src, size_t size) +{ + size_t len1 = strlen(dst); + size_t len2 = strlen(src); + size_t ret = len1 + len2; + + if (len1 + len2 >= size) + len2 = size - (len1 + 1); + + if (len2 > 0) { + memcpy(dst + len1, src, len2); + dst[len1 + len2] = 0; + } + + return ret; +} +#endif + +#ifndef HAVE_STRLNCAT +/* + * see strlcat(), but never cat more then n characters. + */ +size_t +strlncat(char *dst, const char *src, size_t size, size_t n) +{ + size_t len1 = strlen(dst); + size_t len2 = strlen(src); + size_t ret = len1 + len2; + + if (len2 > n) + len2 = n; + + if (len1 + len2 >= size) + len2 = size - (len1 + 1); + + if (len2 > 0) { + memcpy(dst + len1, src, len2); + dst[len1 + len2] = 0; + } + + return ret; +} +#endif + static const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char Pad64 = '='; diff --git a/src/version.c.SH b/src/version.c.SH index f61218e19..9225e4252 100644 --- a/src/version.c.SH +++ b/src/version.c.SH @@ -91,12 +91,10 @@ char *unrealcredits[] = "{X} (Laurie) x@tspre.org", "- Making the main code/design of UnrealIRCd/32 gui", " bugfounds, etc", - "www.secure-tech.net", + "Phil Veale - email@philipveale.com - www.flame.tiefighter.org", "- Donating webhosting", "TheDarkOne & x-irc.net", - "- Donating DNS and development shells", - "irc4ever.net", - "- Donating backup DNS", + "- Development shells", "RaYmAn (Jens Andersen)", "- Supporting with hardware, software, movies, etc, and for", " a great friendship, and spending a lot of time with sts", @@ -121,8 +119,12 @@ char *unrealcredits[] = " - donation to the UnrealIRCd development", "Jan Knutar (JK@IRC)", " - RAM donation, Shell donations :D, and a hell lot of other stuff", + "ThePlayer", + " - Donation to re-buy tspre.org", "Thanks to Headbang and WonderWal too for hardware+software", "donations", + "powerstorm.net", + " - Donating an alpha shell", " (yes your name can be here too;)", "", " \37These people have helped alpha/betatesting/fixing bugs\37", @@ -139,6 +141,7 @@ char *unrealcredits[] = "nemesis - nemesis@unrealircd.info", "Ron885 - Ron885@unrealircd.info", "iDW-badSol - iDW-badSol@unrealircd.info", + "SciFi - SciFi@unrealircd.info", "", "Thanks to former supporters, and anyone who has helped without", "officially joining the staff", diff --git a/src/win32/Win32GUI.c b/src/win32/Win32GUI.c index 09cb7347a..dfc62d85a 100644 --- a/src/win32/Win32GUI.c +++ b/src/win32/Win32GUI.c @@ -175,23 +175,19 @@ LRESULT RESubClassFunc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { * (c) 2001 codemastr */ typedef struct colorlist { + struct colorlist *prev,*next; char *color; - struct colorlist *next, *prev; } ColorList; ColorList *TextColors = NULL; void AddColor(char *color) { ColorList *clist; - clist = MyMalloc(sizeof(ColorList)); + clist = MyMallocEx(sizeof(ColorList)); if (!clist) return; clist->color = strdup(color); - clist->prev = NULL; - clist->next = TextColors; - if (TextColors) - TextColors->prev = clist; - TextColors = clist; + AddListItem(clist,TextColors); } ColorList *DelNewestColor() { @@ -207,14 +203,13 @@ ColorList *DelNewestColor() { } void WipeColors() { - ColorList *clist, q; + ColorList *clist, *next; - for (clist = TextColors; clist; clist = clist->next) + for (clist = TextColors; clist; clist = next) { - q.next = clist->next; + next = clist->next; MyFree(clist->color); MyFree(clist); - clist = &q; } } @@ -267,6 +262,7 @@ DWORD CALLBACK RTFToIRC(int fd, char *pbBuff, long cb) { char cmd[15], value[500], color[25], colorbuf[4]; char colors[16]; pbBuff++; + TextColors = NULL; bzero(buffer, cb); for (; *pbBuff; pbBuff++) { if (*pbBuff == '\r' || *pbBuff == '\n')