Commit Graph

136 Commits (161c1ad680e3a76f61c48793e349f0df9ed81e36)

Author SHA1 Message Date
Klemens Nanni cdd4ccf16f Open save file once in uiLoad() and keep it open until uiSave()
Opening the same file *path* twice is a TOCTOU, although not a critical
one: worst case we load from one file and save to another - the impact
depends on how and when catgirl is started the next anyway.

More importantly, keeping the file handle open at runtime allows us to
drop all filesystem related promises for `-s/save' on OpenBSD.

uiLoad() now opens "r+", meaning "Open for reading and writing." up
front so uiSave() can write to it.  In the case of a nonexistent save
file, it now opens with "w" meaning "Open for writing.  The file is
created if it does not exist.", i.e. the same write/create semantics as
"w" except uiLoad() no longer truncates. existing files.

uiSave() now truncates the save file to avoid appending in general.
2021-06-11 20:57:40 -04:00
Michael Forney 0a1cfca0f4 Avoid creating out-of-bounds pointer when checking for seprintf truncation
It is technically undefined behavior (see C11 6.5.6p8) to construct
a pointer more than one past the end of an array. To prevent this,
compare n with the remaining space in the array before adding to
ptr.
2021-06-09 17:54:26 -04:00
C. McEnroe dfc3ac95c1 Remove catf 2021-06-09 11:56:49 -04:00
C. McEnroe e066a954f5 Replace catf with seprintf 2021-06-09 11:56:35 -04:00
C. McEnroe 5c3cd59af6 Add seprintf
Based on seprint(2) from Plan 9. I'm not sure if my return value
exactly matches Plan 9's in the case of truncation. seprint(2) is
described only as returning a pointer to the terminating '\0', but
if it does so even in the case of truncation, it is awkward for the
caller to detect. This implementation returns end in the truncation
case, so that (ptr == end) indicates truncation.
2021-06-09 11:41:15 -04:00
C. McEnroe f559322224 List windows with /window
Reuse the /window command to preserve /wi abbreviation.
2021-05-28 20:40:25 -04:00
C. McEnroe 6d5bcf72c1 Hash the username in kiosk mode
So that the first part of $SSH_CLIENT can be passed as username.
2021-05-27 11:45:47 -04:00
C. McEnroe 6207aaf1a8 Ignore messages in reply to previously ignored messages
Using the +draft/reply client tag, which is supported by BitBot.
This hides the bot's replies to ignored users or ignored bot command
messages.

This commit is dedicated to the land of Estonia.
2021-05-04 15:34:27 -04:00
C. McEnroe df6bc07f44 Skip STATUSMSG prefixes
This feature is rarely used, so just skip STATUSMSG prefixes in the
target so messages get routed correctly.
2021-04-02 17:26:43 -04:00
C. McEnroe 8ea881a097 Show where too-long-messages will be automatically split 2021-03-17 13:34:33 -04:00
C. McEnroe 6435dfdda5 Disable nick and channel colors with hash bound 0 2021-03-08 10:47:18 -05:00
C. McEnroe 761979d33e Use separate reply counts for automatic join topics/names
This restores showing the topic and names for automatic joined
channels, while still avoiding touching the windows, by using Cold
heat.
2021-02-21 14:23:17 -05:00
C. McEnroe b4c26a2cab Measure timestamp width using ncurses
This allows for non-ASCII characters in timestamps, and simplifies
things by including the trailing space in the width.
2021-01-27 14:55:31 -05:00
C. McEnroe c118c594e3 Add toggleable display of timestamps 2021-01-27 00:15:46 -05:00
C. McEnroe 52c58128c8 Add numbers to buffer lines
This directly correlates hard-wrapped lines with the soft lines
they were wrapped from.

Choosing uint here because it doesn't change the size of struct
Line. It doesn't at all matter since buffers only hold 1024 lines
at a time anyway.
2021-01-26 22:14:12 -05:00
C. McEnroe 95bb627ffb Separate kiosk mode from restrict mode
Restrict mode will focus on sandboxing, while kiosk will continue
to restrict IRC access through a public kiosk. Kiosk mode without
restrict mode allows execution of man 1 catgirl with /help, assuming
external sandboxing.

The /list and /part commands are also added to the list of disabled
commands in kiosk mode, since they are pointless without access to
/join.
2021-01-23 00:48:15 -05:00
C. McEnroe 5a490945ea Rename ignore code to filter 2021-01-16 13:36:39 -05:00
C. McEnroe d05872303e Generalize ignore toggling to visibility threshold 2021-01-16 12:58:16 -05:00
C. McEnroe 51c92f94ff Save and load the URL ring in the save file 2021-01-11 18:05:22 -05:00
C. McEnroe c6cd90c2dd Print chain to stdout with -o 2021-01-10 18:00:41 -05:00
C. McEnroe e42b3aa08e Add -o and -t options to trust self-signed certificates 2021-01-09 19:11:57 -05:00
C. McEnroe a324795b86 Allow configuring the upper bound of the hash function
This allows limiting the nick colors used to the 16-color terminal set
without modifying the TERM environment variable. Produces different
results from just using the default configuration in a 16-color
terminal, but what can you do?
2021-01-09 17:58:29 -05:00
C. McEnroe 4b883177dc Split ignore fields to avoid over-eager * matching
Split ignore fields and match each separately to avoid an early *
eagerly matching across several fields. For example, "* JOIN * *" should
not match messages which happen to contain the word "JOIN" followed by
two other words.

Ignore capacity is reduced to 64 to keep the size of the array the same.
I don't think it's an issue.
2021-01-01 20:09:10 -05:00
C. McEnroe 519fcc436f Factor out reply count checking and decrementing 2020-12-30 16:54:03 -05:00
C. McEnroe 8b6a476c35 Add /whowas 2020-12-30 14:29:32 -05:00
C. McEnroe 05fbcb41c9 Show setnames like nick changes 2020-12-30 00:19:52 -05:00
C. McEnroe 1662b01a5f Add /setname command
I'm not sure about that replies check in handleStandardReply. If more of
those are added the reply counter system will definitely need
refactoring.
2020-12-29 23:54:30 -05:00
C. McEnroe 59006d18bb Avoid eating C-c while connecting
Split UI initialization into two steps either side of the call to
connect, so that C-c works as interrupt while it's blocked.
2020-10-12 19:25:08 -04:00
C. McEnroe c48672313b Factor out styleStrip 2020-10-09 18:45:52 -04:00
C. McEnroe f7f5acbbe2 Double up /help for server help
While the automatic search via LESS is neat, I don't think it's very
useful. Just always open the manual to the COMMANDS section, and fix it
to append to LESS rather than replace it.
2020-10-02 19:38:37 -04:00
C. McEnroe f3a56b0d01 Use WHO for /ops
Accumulate names in a buffer and show away status.
2020-09-30 19:21:34 -04:00
C. McEnroe 3e67bf6557 Add /ops command
It's pretty awkward with large channels since NAMES isn't sorted by
prefixes or anything... But having it accumulate names across many
replies would require more reworking.
2020-09-30 17:52:39 -04:00
C. McEnroe 0968a8ac7c Recalculate unreadHard on reflow 2020-09-02 21:29:03 -04:00
C. McEnroe 96386adac3 Hide ignored messages at the soft -> hard buffer layer
This restores normal scrolling behaviour.
2020-09-02 18:51:07 -04:00
C. McEnroe d00b3d3b70 Actually insert blank lines in the soft buffer
So they can be preserved forever!
2020-09-02 16:29:38 -04:00
C. McEnroe 149cafc5ab Render one main window from buffers
Still missing: split scrolling and preserving a blank on reflow either
from resize or ignore toggling.

Anecdata: on one of my instances of catgirl, RAM usage of the previous
release was ~30M, RAM usage of this commit was ~12M.
2020-09-02 00:27:16 -04:00
C. McEnroe 4dc87ab9cd Implement buffer line wrapping
Not yet rendered in the UI! Just done in parallel.
2020-09-01 22:54:26 -04:00
C. McEnroe ded2b6afb6 Factor buffer out of ui
In preparation for doing line wrapping outside of ncurses.
2020-09-01 20:36:50 -04:00
C. McEnroe a98fd70aac Move styleParse out of ui 2020-09-01 18:05:17 -04:00
C. McEnroe 8190d76086 Use a static buffer for base directory paths 2020-08-21 16:49:10 -04:00
C. McEnroe d9a0364cb4 Use configPath to load TLS cert/priv 2020-08-20 14:56:13 -04:00
C. McEnroe f432bd72fa Refactor base dir functions to iterate over paths 2020-08-20 14:08:51 -04:00
C. McEnroe 814c36223a Say "OpenSSL" in additional permission notices
LibreSSL is "a modified version of that library".
2020-08-04 12:19:14 -04:00
C. McEnroe 4c1b1fc6a3 Replace catf with something that tracks len
Also the old catf would be broken with -DNDEBUG oops!
2020-07-30 14:37:46 -04:00
C. McEnroe a142ebcf43 Define explicit_bzero using memset_s on macOS 2020-07-30 13:36:17 -04:00
C. McEnroe 5a3b63e444 Remove use of strlcat
catf is not better though and should really be replaced.
2020-07-30 13:05:24 -04:00
C. McEnroe 94fb9798c5 Bump ParamCap to 254
Apparently IRCds have decided that the 15-parameter limit doesn't matter
anymore. 254 is the maximum number of single-byte parameters (following
a single-byte command) which fit in a 512-byte CR-LF-terminated line.
When everyone decides that the 512-byte line length limit doesn't matter
either, I will delete my software and people can use some JavaScript
garbage instead.

This makes struct Message 2080 bytes, but there's only ever one or two
of them around at once. Avoid passing it by value to handle.
2020-06-24 13:36:24 -04:00
C. McEnroe 721c3a9ee6 Add additional permission for linking with LibreSSL
https://www.gnu.org/licenses/gpl-faq.en.html#GPLIncompatibleLibs
2020-06-08 17:48:07 -04:00
Michael Forney bde0f47a70 Mark global variables in chat.h as extern
This fixes the build with gcc 10, which enables -fno-common by
default.
2020-05-07 20:00:33 -04:00
C. McEnroe 73bda18110 Check ignores against id
Otherwise they do not work correctly for QUIT and NICK. This also lets
you ignore private messages only by putting the nick in the third field.
2020-04-07 13:18:42 -04:00