1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00
Commit Graph

5273 Commits

Author SHA1 Message Date
John Hernandez
3a4cd7da48 Cleanup and mem leak fix
Improve usage of `gchar` and `char` by setting them correctly
Increase usage of `auto_gchar` and `auto_char`
Fix 2 mem leaks (rosterwin.c, avatar.c)
2023-07-12 17:43:33 +02:00
Michael Vetter
9451ea7c4c Mention DEV for doap in release guide 2023-07-12 14:09:55 +02:00
Michael Vetter
62e98dee74 Fix crash when using NetBSD curses implementation
Thanks to @alarixnia fot the patch and bugreport.

```
Forwarding a bug reported using the NetBSD bug tracker ("Profanity crashes at login"): http://gnats.netbsd.org/57050

The code in question here handles messages by people not in the user's contact list, and what is probably happening is that the XMPP server is sending such a message before profanity has set up its window layout.

Setting roster.unsubscribed=false indeed makes profanity start without crashing, and the attached patch bails out early in the problematic code path if layout->subwin is NULL (Adrian verified for me that either of the two makes profanity work for him again). But I am not familiar enough with the profanity code to say if this has any issues.

Profanity compiled with ncurses doesn't crash because ncurses's wattron() has a guard against the user passing null pointers, but the X/Open curses library standard doesn't have this guarantee and there's no guard in the NetBSD curses implementation.
```

Fix https://github.com/profanity-im/profanity/issues/1769
2023-07-12 13:58:03 +02:00
John Hernandez
00bea804e2 Improve documentation two functions
Namely `cmd_process_input()` and `files_get_data_path()`.

Edited by @jubalh.
2023-07-11 13:26:37 +02:00
John Hernandez
e1d137f4e6 Change char->free to auto_char char for autocleanup
Replace `gchar` and `g_free` to `auto_gchar`
Correct certain  `char` functions/variables to `gchar`

Related to #1819.

Edited by @jubalh.
2023-07-11 13:26:37 +02:00
John Hernandez
07fcaa7be3 Fix memory leak and cleanup 2023-07-03 16:06:27 +02:00
John Hernandez
4a70f5f513 Cleanup char* to auto_gchar gchar* for prefs_get_string
Necessity explained in #1819
2023-07-03 16:06:27 +02:00
John Hernandez
1c102fec27 Add /privacy logging command
Add ability to completely turn logs off,
Needed since `/logging` and `/history` didn't stop history logging
in the DB, only in files.
Command might break something on usage,
hence it was primarily introduced for privacy geeks.
Privacy command discussion #1836
2023-07-03 16:06:24 +02:00
Michael Vetter
f67d548ebf
Merge pull request #1850 from H3rnand3zzz/feature/pgp-improved
Extend `/pgp` command to make key exchange procedure easier
2023-07-03 14:18:35 +02:00
John Hernandez
7d6cbfdcd2 Refactor autocomplete
Use `_cmd_ac_complete_params` when fits, thus reducing plurality
2023-07-02 14:25:55 +02:00
John Hernandez
36784738fc Add optional pgp public key autoimport
Refactor `p_gpg_list_keys`
Add `/pgp autoimport` command,
it's not described in XEP-0027, but used in some clients,
such as PSI, Pidgin. It will autoimport keys received with
`/pgp sendpub`, in plain text as a message, or using features,
provided in other clients. It doesn't autoassign them, but shows
command to assign, letting user to decide.
Improve documentation for some preexisting functions
Add contact argument to `/pgp sendpub`
2023-07-02 14:25:55 +02:00
John Hernandez
349e4cb322 Refactor _cmd_set_boolean_preference function
Improve documentation
Update code formatting and indentation for better readability
Show state if no argument provided
Show if argument wasn't changed
Reduce amount of arguments
2023-07-02 14:25:55 +02:00
John Hernandez
a59623a007 Add /pgp sendpub command
Command allows to share your PGP pub key with ease,
it's not described in XEP-0027, but used in some clients,
such as PSI, Pidgin.
Fix typos
Minor improvements
2023-07-02 14:25:55 +02:00
Michael Vetter
6247c28e31
Merge pull request #1842 from H3rnand3zzz/feature/plugins-download
New Feature: Plugins Download
2023-06-06 18:35:18 +02:00
Steffen Jaeckel
88d383b052 Fix double-free of values.
The strings have to be dup'ed, otherwise we'll free them twice.

Fixes #1855

Introduced by b6bb50ceb2

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-06-04 13:39:03 +02:00
Michael Vetter
14a2dfc711 Expand /url description 2023-05-31 19:51:19 +02:00
Steffen Jaeckel
b6bb50ceb2 Fix use-after-free
introduced in 8d3c1f79ac

This fixes #1852

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-21 11:02:14 +02:00
Steffen Jaeckel
c0861eed49 Improve debug logging
Tell the user that a MAM request will be issued delayed instead of showing
a warning that MAM isn't supported by the server.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-21 11:00:32 +02:00
Steffen Jaeckel
638b15c6d9 Fix memleak
introduced in 5d3c8ce7c1

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-21 10:59:13 +02:00
John Hernandez
95e06ad169 Add url support (downloading) to /plugins install
Additional changes include code refactoring.
2023-05-16 15:57:07 +02:00
Steffen Jaeckel
d8eea87f60 Fix -Werror=maybe-uninitialized
When compiling with `CFLAGS="-O2 -fexceptions -Wp,-D_FORTIFY_SOURCE=2"`, as
done per default when creating an AUR package e.g. via `makepkg`, this
error is produced.

Refactor `stanza_create_mam_iq()` in order to fix said warning-turned-into-
an-error.

Edit by jubalh:
I still think the error message is a false positive. But this commit improves the
code a lot.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-12 08:39:29 +02:00
Steffen Jaeckel
197b839944 Remove VLA & calm Valgrind
`MB_CUR_MAX` looks like a macro, but it's a function call and therefore
creates a VLA. We don't want that.

Also this array being uninitialized created the following Valgrind error

```
==503529== Conditional jump or move depends on uninitialised value(s)
==503529==    at 0x619F15E: waddnstr (lib_addstr.c:67)
==503529==    by 0x1929B7: _inp_write (inputwin.c:353)
==503529==    by 0x1937D5: _inp_redisplay (inputwin.c:619)
==503529==    by 0x61511B1: rl_forced_update_display (display.c:2693)
==503529==    by 0x193F9D: _inp_rl_send_to_editor (inputwin.c:957)
==503529==    by 0x614642F: _rl_dispatch_subseq (readline.c:916)
==503529==    by 0x6146C85: _rl_dispatch_callback (readline.c:823)
==503529==    by 0x616739F: rl_callback_read_char (callback.c:241)
==503529==    by 0x1923DB: inp_readline (inputwin.c:188)
==503529==    by 0x149860: prof_run (profanity.c:117)
==503529==    by 0x2283E8: main (main.c:186)
==503529==  Uninitialised value was created by a stack allocation
==503529==    at 0x1928B1: _inp_write (inputwin.c:334)
```

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-12 08:39:23 +02:00
Steffen Jaeckel
12d76e4a21 Fix memleaks & more auto-free
`data_dir` would have been leaked if directory creation failed.

`editor_argv` was leaked at some point, no idea why.

```
==1244734== 118 (32 direct, 86 indirect) bytes in 1 blocks are definitely lost in loss record 6,299 of 7,824
==1244734==    at 0x4846CC3: realloc (vg_replace_malloc.c:1451)
==1244734==    by 0x5E85AD0: g_realloc (in /usr/lib/libglib-2.0.so.0.7600.1)
==1244734==    by 0x5E4A004: ??? (in /usr/lib/libglib-2.0.so.0.7600.1)
==1244734==    by 0x5E4A7B1: g_ptr_array_add (in /usr/lib/libglib-2.0.so.0.7600.1)
==1244734==    by 0x5EA4235: g_strsplit (in /usr/lib/libglib-2.0.so.0.7600.1)
==1244734==    by 0x1F143C: get_message_from_editor (editor.c:92)
==1244734==    by 0x193F6B: _inp_rl_send_to_editor (inputwin.c:950)
==1244734==    by 0x614642F: _rl_dispatch_subseq (readline.c:916)
==1244734==    by 0x6146C85: _rl_dispatch_callback (readline.c:823)
==1244734==    by 0x616739F: rl_callback_read_char (callback.c:241)
==1244734==    by 0x1923DB: inp_readline (inputwin.c:188)
==1244734==    by 0x149860: prof_run (profanity.c:117)
==1244734==    by 0x2283E8: main (main.c:186)
```

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-12 08:39:20 +02:00
Steffen Jaeckel
76a8de891e Improve const-correctness of API
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-12 08:39:19 +02:00
Steffen Jaeckel
860dd22bc5 Fix potential double-free
introduced in 8d3c1f79ac

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-12 08:39:16 +02:00
John Hernandez
9a68aab011 /url save and /url open refactoring
Additional changes: jid.c minor refactoring
2023-05-11 09:44:55 +02:00
Michael Vetter
ea35a4ceb0
Merge branch 'master' into cleanup/gchar-char 2023-05-11 08:45:46 +02:00
Michael Vetter
209a8f4bf5
Merge pull request #1847 from profanity-im/minor-improvements
Minor improvements
2023-05-11 08:43:37 +02:00
Steffen Jaeckel
8d3c1f79ac fix memory leaks
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-10 18:12:11 +02:00
Steffen Jaeckel
8cd53acfd7 fix /reconnect now
This fixes #1846
Issue introduced by a0aa26b6fa

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-10 18:12:11 +02:00
Steffen Jaeckel
08d68d329b more auto_char
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-10 18:08:09 +02:00
Steffen Jaeckel
7d9c3c1b32 fix "window NULL issue" (hopefully)
There were multiple reports where after a reconnect the window of the
MUC that was last opened, was empty.

`muc_join()` creates an instance of a MUC, `presence_join_room()` works
with this instance. Therefore the instance has to exist before working on
it.

I'm not sure if this really fixes the issue, but at least it didn't
happen anymore after I applied this modification.
I can't remember how I stumbled over this, either while looking at debug
logs or while looking at Valgrind output while a reconnect happened, but
something went wrong. Then I came to the conclusion that this may fix
the issue and for now it did ... maybe it comes back, then my RCA was
wrong.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-10 17:51:52 +02:00
Michael Vetter
60c197487d Add helper function for individual cmd_executable_*() functions
Each of the cmd_executable_editor(), cmd_executable_urlopen() etc calls
this helper function since they were all doing the same just for
different configurations.
2023-05-10 09:41:59 +02:00
Michael Vetter
79efe56d64 Add autocompletion for /executable parameters
We autocompleted `/executable` to `avatar`, `vcard_photo`, `editor` etc.
But didn't autocomplete the next parameter. Namely `set` and `default`.
2023-05-10 09:34:52 +02:00
Michael Vetter
46c90bc681 Make it possible to reset editor to default
All the other commands (avatar, vcard_photo, urlsave, urlopen) have the
ability to reset to default already.
2023-05-10 09:34:52 +02:00
Michael Vetter
a7159c5954 Add vcard_photo to /executable autocompletion
Was forgotten in f934c5b59.
2023-05-10 09:34:52 +02:00
Michael Vetter
8075b32ebc Align avatar behaviour with urlopen
`/executable avatar` now also uses cmdtemplate and parse %p.
It seems to me that the `/avatar` command was actually completely broken
on master.
2023-05-10 09:34:48 +02:00
Michael Vetter
daf3d193e2 Remove parsing of /avatar cmd
This is done in `/executable avatar set` since d7848e38b.
The command help also didn't mention this anymore.
Seems like it was forgotten to remove the actual parsing of this.
2023-05-10 09:21:32 +02:00
John Hernandez
7f3fca2bd0 Cleanup: gchar as gchar instead of char
Use gchar instead of char in most of the cases where gchar is intended.

Reason: improve compatibility and stability. Issue #1819

Minor refactoring.
2023-05-04 16:15:09 +02:00
IsaacM88
ecdeb750f3 Add ability to disable avatar publishing
Add "/avatar disable" to comply with point "3.5 Publisher Disables
Avatar Publishing" in XEP-0084.

src/command/cmd_defs.c:2416
Add "disable" argument. Reword the "/avatar" command description
so it flows better.

src/command/cmd_ac.c:1101
Add "disable" to the "/avatar" autocomplete dictionary.

src/command/cmd_funcs.c:9277
Split "/avatar" commands into two groups with an if statement; those
with a parameter and those without. "cons_bad_cmd_usage()" is in both
groups, which is messy. "disable" has similar logic to "set", but it
includes a failure message.

src/xmpp/avatar.c:152
"avatar_publishing_disable()" uses the same logic to publish metadata
as in "avatar_set()".

src/xmpp/avatar.c:238
Add a message to inform users when they do not receive an avatar after
using "/avatar get" and "/avatar open". In case of a failure, the user
will be subscribed to future avatar updates as long as they continue
to use their current instance of profanity. Adding
"caps_remove_feature()" after "cons_show()" will unsubscribe the user
from avatar updates and prevent the user from downloading an avatar
unexpectedly hours later without issuing an "/avatar" command.

src/xmpp/stanza.c:2698
The new "disable" function follows the same logic as
"stanza_create_avatar_metadata_publish_iq()".
2023-05-02 14:45:54 -06:00
Michael Vetter
f4d418a95f
Merge pull request #1838 from H3rnand3zzz/fix/omemo-trust-notification
Improve OMEMO messages
2023-04-19 17:53:27 +02:00
Michael Vetter
3be09147d7
Merge pull request #1840 from H3rnand3zzz/fix/plugins-unload
Fix `/plugins update`
2023-04-19 17:52:39 +02:00
John Hernandez
a54e5413ca Fix /plugins update
Before it tried to unload the plugin first and check the output.
But if broken plugin was loaded, then it couldn't unload it,
so before it require uninstall and install after it,
making update useless for plugin development purposes.

Unload is part of the uninstall so no unload is needed inside of the cmd function.

Refactoring of cmd_plugins_update.
2023-04-19 03:29:23 +02:00
John Hernandez
26e97d4e80 Improve OMEMO messages 2023-04-19 00:34:17 +02:00
Michael Vetter
f20dbcff09 Fix memleak in _inp_rl_linehandler
Introduced in 59b99fece.
2023-04-18 21:30:05 +02:00
Michael Vetter
abaf96dcef Fix memleak in stanza_create_caps_query_element
Got introduced with 5d3c8ce7c.
2023-04-18 20:26:24 +02:00
John Hernandez
96ddb2399e Add logging consistency
Since MUC private messages are not logged by design,
part where this logging happening is removed to add consistency.

Add explanation in comment.
2023-04-18 18:19:47 +02:00
John Hernandez
5a1f2dedd3 Fix /log level crash
Fix crash caused by `/log level` command.

Minor refactoring of command function.
2023-04-18 18:16:57 +02:00
Michael Vetter
4933d4e4f3
Merge pull request #1827 from H3rnand3zzz/feature/sessions-alarm
New Feature: Session Alarm
2023-04-18 14:43:01 +02:00
John Hernandez
07cc19ce10 Add sessions_alarm
Introduce new feature: sessions_alarm.

Added new account setting: max_connections. On exceeding this number,
user will get an alert. If number is less than 1, no alert will happen.

Tests altered to fit new feature.
2023-04-18 14:28:20 +02:00