Thomas Sader [Sun, 12 Feb 2023 19:21:20 +0000 (20:21 +0100)]
Workaround for TCL_UTF_MAX==3
Found by: Empus
Patch by: thommey Fixes: #1163
Ugly workaround that does not break current usage of emoji in the Tcl API. Our usage of the Tcl API is not correct because Eggdrop is encoding agnostic, and processes byte arrays only. Those however get passed to Tcl as strings, when they are not. The real solution is fairly complex (decode all bytes into strings with the proper encoding guess from/to the Tcl API).
If users are unable to recompile Tcl with increased TCL_UTF_MAX and are stuck with 8.6 stable (8.7 is not released as stable at the time of this PR), this should be a suitable, albeit ugly and complex, workaround that keeps emoji support alive.
We do not wish to break the currently working emoji usage however, which mostly works in the current state, except for a crash if passed to [string tolower/toupper/totitle], other problematic call sites aren't known.
So we overwrite Tcl's string tolower/toupper/totitle with our own version that:
detects utf-8 sequences that are 4 bytes
converts them into utf-8 encoded surrogate pairs before Tcl's string functions are called
those remain untouched by case changes in Tcl
convert the surrogate pairs back in the result to the original utf-8 4-byte code sequences
Side effect is that we also convert surrogate pairs if they were sent as such, which should not have a negative impact on existing scripts.
Single-byte encodings being valid 4-byte emoji sequences or 6-byte surrogate pairs is hopefully highly unlikely.
Michael Ortmann [Mon, 19 Dec 2022 15:41:20 +0000 (15:41 +0000)]
Fix some year 2038 problems
Found by: michaelortmann
Patch by: michaelortmann and thommey
Fix time_t handling (buffer size, type and format specifier)
POSIX requires time_t to be an integer type, but does not mandate that it be signed or unsigned.
time_t to string conversion used buffersize 11, 10 chars + NULL-terminator, would overflow with unixtime >9999999999 (year 2286)
Thomas Sader [Thu, 10 Nov 2022 17:06:04 +0000 (18:06 +0100)]
Fix matchattr without flags
Fixes: #1267
The matchattr/bind flag string "-" or "-|-" is commonly used to match "anyone".
It isn't a real match because there are no flags specified so there is nothing
to match. - and | are just meta-characters that don't parse to modes that can match.
Michael Ortmann [Wed, 5 Oct 2022 23:41:41 +0000 (23:41 +0000)]
Avoid freeaddrinfo(NULL)
Found by: Release_
Patch by: michaelortmann Fixes: #1329
The behavior of freeadrinfo(NULL) is left unspecified by RFC 3493. Some Operating Systems like FreeBSD handle this for compatibility / portability but others like OpenBSD do not (as reported in #1329), so let eggdrop avoid calling freeadrinfo(NULL).
Michael Ortmann [Tue, 27 Sep 2022 01:19:53 +0000 (01:19 +0000)]
Fix format specifier for intptr_t
Found by: michaelortmann
Patch by: michaelortmann
Fix format specifier for intptr_t with c99 PRIdPTR that were shadowed by the use of egg_snprintf() and simple_sprintf() / use snprintf() for all getudef()
Thomas Sader [Sun, 18 Sep 2022 19:06:08 +0000 (21:06 +0200)]
Eggdrop no longer interprets WHO response it didn't request in the WHOX case
The response could have different arguments, so we now validate our query type
parameter is in the response. Tcl scripts wanting to poll WHO and eggdrop
to parse it, must send query type 222 in the same format as eggdrop requests it.
Change RAWT tags to properly handle as a dict, not string
Properly log TAGMSG messages
Fix Twitch to handle change (while still preserving previous API)
Geo [Sat, 27 Aug 2022 18:01:06 +0000 (14:01 -0400)]
Fix bad +host logmsg
Found by: thommey
Patch by: Geo
As part of the account tracking PR, a new shared function was added for +host and +account, but only +account checked the new return value of this function for an error in order to not display the "successful" message
Thomas Sader [Sat, 27 Aug 2022 15:29:03 +0000 (17:29 +0200)]
Fix format specifiers
Patch by: thommey Fixes: #1176
Needs to be tested and compile tested on various platforms if possible.
Uses difftime() to print time_t when possible because printing time_t portably is very hard.
* Add compiler format specifier checking where possible
* Fix various printf-style specifiers and arguments
* add format specifiers
Thomas Sader [Wed, 24 Aug 2022 18:14:42 +0000 (20:14 +0200)]
Fixes a DNS bug when DCC connections were disconnected while the DNS request was pending. Fixes #1174 (#1319)
Found by: DasBrain, ERR1R, CrazyCat
Patch by: thommey Fixes: #1174 #1175
In a host->IP scenario, devent_t contains a malloc'd copy of the hostname.
In the IP->host scenario however, devent_t contained an outside allocated pointer
to ip_addr (sockname_t).
In the Tcl case it was embedded in the tclinfo structure, but in the DCC case
it pointed to the idx information in dcc[i].
"Lost connection" wipes that idx info and invalidates it, invalidating
the information about the pending dns request. That would then get stuck with
invalid data.
As soon as the idx is re-used however, the address is overwritten by answer(),
and dns thinks it already sent a request for that IP, also it gets stuck.
The fix treats IP->host the same as host->IP and dynamically allocates the IP
as it does with the hostname.
Geo [Wed, 24 Aug 2022 18:13:10 +0000 (14:13 -0400)]
Move gotmsg back to raw bind
Found by: CrazyCat
The gotmsg function was inadvertently moved to the rawt bind table from the raw bind table, which could cause issues with previously-written scripts attempting to unbind this internal functionality reference.
eryg-kai [Sun, 7 Aug 2022 17:42:01 +0000 (12:42 -0500)]
Fix plain SASL when TLS unavailable
Found by: @eryg-kai
Patch by: @eryg-kai
Fix plain SASL auth when TLS is unavailable
There is common code after the if/else that was being omitted by an ifdef that should only be affecting the last else branch. This change brings this ifdef in line with the previous ifdef (utilizing an early `return 1`).
Instead modify finduser to search for account records in userfile
The desired functionality of account2hand will be present in the next release's version of nick2hand, so no need to create a superfluous command now
Michael Ortmann [Sat, 18 Jun 2022 03:57:45 +0000 (03:57 +0000)]
Update inet_aton.c from FreeBSD uptream removes advertising clause (#967)
Found by: michaelortmann
Patch by: michaelortmann
The new https://github.com/freebsd/freebsd/blob/455de2f90f71a495eb5068b060c17de9bfcffda6/lib/libc/inet/inet_addr.c removes advertising clause from license. The only user of inet_aton() within eggdrop is one function in dns module. I tested this function and enhanced its logging.
Michael Ortmann [Sat, 18 Jun 2022 03:48:00 +0000 (03:48 +0000)]
remove Context from modules
Found by: michaelortmann
Patch by: michaelortmann
Remove Contexts that are artifacts, that dont help us debug eggdrop, instead they are even misleading. For example, when the twitch mod does Context; and (much) later the bot crashes, it will point into twitch mod, where the last Context; was set, even if the bug is outside twitch mod.
Geo [Fri, 17 Jun 2022 02:22:02 +0000 (22:22 -0400)]
Add account tracking to Eggdrop
This merge adds a basic account tracking capability to Eggdrop. Reliable account tracking requires three server components: WHOX responses enabled, the extended-join capability, and the account-notify capability. Without WHOX supported by the server and extended-join and account-notify capabilities negotiated, account tracking is not reliable. To make this check easy for Tcl scripts, the "accounttracking" variable was implemented and can be easily checked to see if account-tracking is currently in a reliable state. Other major changes this PR implements:
- Adds ACCOUNT getuser/setuser setting
- Adds +account/-account commands to command line, to add an account to a handle
- Adds account2hand Tcl command that takes a nickname, checks if an account is associated and, if so, returns the handle the account is added to (if any)
Michael Ortmann [Mon, 6 Jun 2022 03:51:23 +0000 (03:51 +0000)]
simplify main loop
Found by: michaelortmann
Patch by: michaelortmann
1. mainloop() is only called in main.c, so i removed it from proto.h and made it static
2. the return value of mainloop() is not used, so i made it void
3. garbage_collect() is a mechanism to call garbage_collect_tclhash() every 3rd second. there is already a mechanism in mainloop() doing cleanup every 5th second. so i fused garbage_collect() into that cleanup block.