1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-29 19:56:07 -04:00
Commit Graph

4141 Commits

Author SHA1 Message Date
Michael Vetter
4d7a496ae2 Change origin-id/id algo
Hash twice.
Use HMAC SHA256 from glib.
2019-10-18 16:12:26 +02:00
Michael Vetter
06f300a42c Move message sent by us logic in own function 2019-10-18 14:50:25 +02:00
Michael Vetter
dfead6415f sv_ev_room_message: log in all cases if not our client
Forgot to check what happens if the length is <= 10.
2019-10-18 11:59:39 +02:00
Michael Vetter
f7474cd72c sv_ev_room_message: check if message->id is not NULL 2019-10-18 11:43:30 +02:00
Michael Vetter
5c6f5ba0f7 Add connection_get_profanity_identifier stub
And move defintion to xmpp.h
2019-10-18 11:23:30 +02:00
Michael Vetter
33083662d1 Add XEP-0359 to capabilities
We implement </origin-id> from [XEP-0359](https://xmpp.org/extensions/xep-0359.html).
We already had this implemented for OMEMO. And now use it to check
whether MUC messages were sent from us
(https://github.com/profanity-im/profanity/issues/1201).

We don't implement </stanza-id> yet, but probably need to do so for MAM.

Anyways let's flag this as implementing the XEP.

Fix https://github.com/profanity-im/profanity/issues/1207
2019-10-18 10:46:06 +02:00
Michael Vetter
430b2eaa0d Log incoming MUC messages if origin-id sais they dont come from us
Regards https://github.com/profanity-im/profanity/issues/1201
2019-10-18 10:40:24 +02:00
Michael Vetter
53640f6e97 Remove prefix from stanza id
We sent `prof_prefix_uuid` as id. Where the prefix was also optional.
We don't need this at all.
2019-10-17 15:40:40 +02:00
Michael Vetter
827af999b7 Change algo for connection_create_stanza_id() 2019-10-17 15:32:46 +02:00
Michael Vetter
8f5d1751b2 Change connection_create_stanza_id()
To return identifier and uuid together.
We can remove the prefix later on.
2019-10-17 09:23:11 +02:00
Michael Vetter
708bc83870 Calculate identifier upon connect
This will be needed so that we can later detect if messages (origin-in)
was sent by us.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 15:53:28 +02:00
Michael Vetter
ee0541a262 Rename identification file 2019-10-16 10:54:05 +02:00
Michael Vetter
46f0304f89 Use random string for random-bytes identifier
And rename `instance` to `identifier`.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 10:45:41 +02:00
Michael Vetter
f9eb302a59 Move code from jid_random_resource() into own function
Move the code that creates a random string into it's own function
+get_random_string().
2019-10-16 10:39:35 +02:00
Michael Vetter
1e09a055ca Create random-bytes file
So far only with dummy value.
We will need an identifier that we can hash together with a message ID
and put in as the origin-id.
So when we receive message we can unsplit it and see if it was sent from
this client.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 10:17:34 +02:00
Dmitry Podgorny
69bba3ea4e plugins/python: fix double _XOPEN_SOURCE definition
ncursesw defines _XOPEN_SOURCE macro via command-line. In particular, it
is defined in ncursesw.pc and extracted via pkg-config. From other side,
Python defines the same macro unconditionally in pyconfig.h. Python-3.x
defines the macro with value different than ncursesw does. In turn, this
causes a warning that the macro is redefined. And warnings are treated
as errors.

Since both entities define the mecro unconditionally, we can't simply
reorder headers as Python developers suggest. So, undefine the macro
just before the <Python.h> to fix this silly issue.
2019-10-15 12:30:38 +00:00
Michael Vetter
d0c3d3fd6b Null-set account struct
Surpresses the valgrind warning about uninit. values.
2019-10-14 11:35:18 +02:00
Dmitry Podgorny
6d11cd2db3 Fix memory leak in cmd_join()
room is either argv[0] or allocated by GString. We have to free memory
in the 2nd case. Replace argv[0] with g_strdup(argv[0]) in order to
make unconditional g_free().
2019-10-14 00:19:08 +03:00
Michael Vetter
5c53e02d86 Add option to hilight unread rooms in /wins command
In the theme we can now set `cmd.wins.unread` to hvae a special color
for the lines of the `/wins` output that have unread messages.

Fix https://github.com/profanity-im/profanity/issues/895
2019-10-12 13:03:14 +02:00
Michael Vetter
87b66d0816 Make cmd_account safer 2019-10-10 18:06:28 +02:00
Michael Vetter
d3dd95963e Sort includes in python_api.c 2019-10-07 15:53:17 +02:00
Michael Vetter
b3ed213668 Improve MUC 1:1 logging
If we get a private message from a user in a MUC profanity shows this
like:
`profanity@roomsASDF.dismail.de/Martin: Hi`

This was so far logged at:
`~/.local/share/profanity/chatlogs/my-account-at-server/profanity_at_rooms.dismail.de/2019_09_04.log` as:

```
10:48:13 - profanity@rooms.dismail.de: Hi
```

So the nickname was not saved anywhere. This is due to us not knowing
whether we got a regular message from user@server.org/resource or a MUC
PM from room@server.org/user.

We now check for `<x xmlns='http://jabber.org/protocol/muc#user' />` and
add the resourcepart to the logging if we get it.

The file will be created at
`~/.local/share/profanity/chatlogs/my-account-at-server/profanity_at_rooms.dismail.de_nick` and look like:

```
23:59:43 - nick: Hi
```

Fix https://github.com/profanity-im/profanity/issues/1184
2019-10-07 00:05:37 +02:00
Michael Vetter
f1d31e024c Fix typo handel -> handle 2019-10-06 23:00:08 +02:00
Michael Vetter
7684cf64f0 Revert "Fix memleak in cmd_join"
This reverts commit 1746f5f8a8.
2019-10-06 22:44:35 +02:00
Michael Vetter
147be3afdf Don't log own messages on incoming MUC
`sv_ev_room_message()` called `groupchat_log_msg_in()` to log all
incoming MUC messages.

`cl_ev_send_muc_msg()` calls `groupchat_log_msg_out()`.

So messages sent by the user himself was logged two times.

Filter the incoming messages and only log the ones not from our occupant
jid/nick.

Fix https://github.com/profanity-im/profanity/issues/1201
2019-10-06 22:32:58 +02:00
Michael Vetter
7d7997e93c Add account clear example to help
Give example on how to clear pgpkeyig.
2019-10-06 20:46:50 +02:00
Michael Vetter
9b3517c21e Free strings in autocomplete_param_no_with_func
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 19:05:27 +02:00
Michael Vetter
94b401ab96 Fix invalid read in muc code
We didn't set the variables to NULL, but the rest of the code depends on
this check.
```
==22201== Invalid read of size 8
==22201==    at 0x44E560: autocomplete_clear (autocomplete.c:69)
==22201==    by 0x427B2C: muc_invites_clear (muc.c:190)
==22201==    by 0x461328: ev_disconnect_cleanup (common.c:59)
==22201==    by 0x463FB5: cl_ev_disconnect (client_events.c:91)
==22201==    by 0x431252: cmd_disconnect (cmd_funcs.c:1234)
==22201==    by 0x47E883: clears_chat_sessions
(test_cmd_disconnect.c:28)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
==22201==  Address 0x814b690 is 0 bytes inside a block of size 24 free'd
==22201==    at 0x48379AB: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22201==    by 0x44E5F7: autocomplete_free (autocomplete.c:90)
==22201==    by 0x4278A0: muc_close (muc.c:97)
==22201==    by 0x47DBAA: cmd_join_uses_password_when_supplied
(test_cmd_join.c:169)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
==22201==  Block was alloc'd at
==22201==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22201==    by 0x44E51B: autocomplete_new (autocomplete.c:57)
==22201==    by 0x427837: muc_init (muc.c:88)
==22201==    by 0x47DA77: cmd_join_uses_password_when_supplied
(test_cmd_join.c:154)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
```
2019-10-06 19:00:46 +02:00
Michael Vetter
1746f5f8a8 Fix memleak in cmd_join
Free `room` string in case we allocated it ourselves.

Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:53:16 +02:00
Michael Vetter
3ce27b47ad Free strings in all cases in cmd_rooms
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:51:04 +02:00
Michael Vetter
b591f0cf2b Free list in error case in parse_options
Fix memleaks.

Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:12:50 +02:00
Michael Vetter
897dfbb3c1 Fix memleak in get_start()
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:42:44 +02:00
Michael Vetter
57ebb7cfa6 Destroy hash table ein autocompleters_destroy()
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:29:35 +02:00
Michael Vetter
10f2715ea9 Free options in error case for cmd_connect()
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:19:17 +02:00
Michael Vetter
4e8f0c90b5 Fix preferences memory leak
Memory leak detected through unit tests.

Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-05 20:45:07 +02:00
Michael Vetter
684a9b1a56 Add /clear autocompletion and improve help
Regards https://github.com/profanity-im/profanity/issues/855

https://github.com/profanity-im/profanity/pull/874 brought us the
`/clear` command. The author of that patch couldn't follow up with the
review boothj5 did.

So the autocompletion and updated help was missing.
This commit adds it.
2019-10-05 16:19:53 +02:00
Michael Vetter
d7c00360ea
Merge pull request #874 from spiridoncha/master
Change /clear behaviour. Closes issue #855.
2019-10-05 15:12:44 +02:00
Michael Vetter
4637a7a23b Merge remote-tracking branch 'philipflohr/master' 2019-10-05 15:04:46 +02:00
Michael Vetter
c135f989ec Check errors in is_dir() is_regular_file()
In case of error print the error. And return right value.

Improvement based on @pasis advice in https://github.com/profanity-im/profanity/pull/1036
Applying in preparation to merge that PR.
2019-10-04 23:29:10 +02:00
Michael Vetter
5c77b97c35 Introduce /reload command
This command reloads the configuration file.

Fix https://github.com/profanity-im/profanity/issues/627
2019-10-04 14:06:25 +02:00
Michael Vetter
523681a642 Log outgoing carbons instead of incoming
Incoming carbons are logged as normal message already.
So we had this logged twice but didn't log outgoing carbons,
send from our account but by another client, at all.

Fix https://github.com/profanity-im/profanity/issues/1181
2019-10-04 13:22:14 +02:00
Michael Vetter
7da2a444da Mention XEP-0191 in blocked command 2019-09-30 19:12:47 +02:00
Michael Vetter
53c4c8548b Document how to block users in MUCs
Regards https://github.com/profanity-im/profanity/issues/618
2019-09-30 19:11:30 +02:00
Michael Vetter
e8420e7235 Bind key to switch to next active window
alt-a brings one to the next window with unread messages.

Regards https://github.com/profanity-im/profanity/issues/1114
2019-09-30 18:28:05 +02:00
Michael Vetter
d6c638c70f Define keybindings to switch to up to 20 windows
alt-2 brings one ot the window.
irssi supports alt + 1234567890qwertyuio to easily switch to 20 windows
instead of just ten.

Hardcode this too.

Regards https://github.com/profanity-im/profanity/issues/1114
2019-09-30 17:42:32 +02:00
Michael Vetter
6ab6fe8649 Detect MUC history correctly with some Prosody versions
Some versions of prosody send the domainpart.
See https://issues.prosody.im/1416

Workaround to handle those cases.
Thanks to Holger Weiss for helping with this!

Fix https://github.com/profanity-im/profanity/issues/1190
2019-09-30 10:01:19 +02:00
Michael Vetter
6161235733 Remove not needed code
Was left over from refactoring a long time ago.
2019-09-29 15:47:24 +02:00
Michael Vetter
d1f388cbd7 Add comment about statusbar.current 2019-09-29 15:47:11 +02:00
Michael Vetter
30875a9069 Fix typo conact -> contact 2019-09-29 15:07:32 +02:00
Michael Vetter
a4e9d9b9e2 Use helper function for cmd_status 2019-09-29 15:07:08 +02:00
Michael Vetter
b961ad29c7 Allow pasing a jid to info command in chat window
If we pass a jid/nick to `/info` in a chat window we will still get the
output. But on the console window.

Regards https://github.com/profanity-im/profanity/issues/1194
2019-09-29 15:04:19 +02:00
Michael Vetter
0f732466f8 Allow pasing a jid to status command in chat window
Regards https://github.com/profanity-im/profanity/issues/1194
2019-09-29 14:58:25 +02:00
Daniel Lublin
641410f6bd Add coloring of statusbar.current tab in view
This theme color applies to the tab title text of the statusbar tab that
is currently shown.

The (somewhat confusingly named) `statusbar.active` theme color now
applies to all other tabs (before, it applied to all tabs).

Coloring of a tab that is highlighted/has new messages is done as before
using the `statusbar.new` theme color.

The default color is set to `cyan`, and thus causes no visible change
for users -- until modified.
2019-09-24 10:35:30 +02:00
Dmitry Podgorny
3ecb5424ae log: set nonblocking mode for stderr
Glib can print error messages to stderr and blocking write freezes
Profanity if the buffer is full. Move stderr to nonblocking mode
in hope that glib will skip printing on EWOULDBLOCK error. In this
case we lose some error messages, but Profanity continues working.
2019-09-13 11:48:31 +00:00
Michael Vetter
6cf06dc516 Log alleged roster push to file
https://gultsch.de/dino_multiple.html mentions CVE-2019-16235, CVE-2019-16236 and CVE-2019-16237.

CVE-2019-16235: Is checking the from in carbon messages. We do that.
CVE-2019-16236: Is checking the from in roster pushes. We do that but
didn't log it yet.
CVE-2019-16237: Is checking the form in MAM messages. We don't support
them yet.
2019-09-12 20:55:16 +02:00
Michael Vetter
2c97a48418 Print history color in theme properties
Also print `main.text.history` setting when `/theme properties' is run.
2019-09-11 13:21:02 +02:00
Michael Vetter
e10f4d4bb0 Set default color for main.text.history
Might be related to https://github.com/profanity-im/profanity/issues/1186
2019-09-11 13:20:32 +02:00
Michael Vetter
aa0f497975 Allow colorization of history messages
History was always printed with `THEME_DEFAULT` we now use
`THEME_TEXT_HISTORY` which is accesible in theme files via
`main.text.history`.

Fix https://github.com/profanity-im/profanity/issues/1170
2019-09-10 11:22:30 +02:00
Michael Vetter
09b6fc9aaa Log 1:1 messages from other clients also to file
Carbons where not logged so far.

Fix https://github.com/profanity-im/profanity/issues/1181
2019-09-04 10:28:52 +02:00
Michael Vetter
09c5f38f11 Set message->plain in carbon case
message->plain should always contain something. In the case of the
carbons we forgot to set if rom the body in case it's empy.
2019-09-04 10:27:03 +02:00
Dmitry Podgorny
8c69d7105b Don't crash if source jid doesn't contain the node part
Profanity uses the node part of a JID as display name for a tab. If such
a JID doesn't contain the node part, Profanity crashes on NULL pointer
dereference.

In the above case, use barejid which is just a domain. Fixes #1153.
2019-08-26 12:46:30 +03:00
Michael Vetter
c100897c9d Hardcode James email adress in info message
Dont rely on PACKAGE_BUGREPORT being James' mail.
2019-08-24 18:07:24 +02:00
Michael Vetter
726eee2a66 Make sure memory in color_pair_cache_reset() was allocated.
Just to be on the safe side.

Probably only relevant for unit tests where ncurses vars are not
initialized with real values.
Fix unit tests on all platforms.
2019-08-24 18:04:02 +02:00
Michael Vetter
03fbf2e77a Remove unused colour_string_t struct 2019-08-23 14:59:26 +02:00
Michael Vetter
7d7a49f132 theme: print to log not to console
Seems this can cause trouble in case we cant use the theme properly.
2019-08-23 14:56:29 +02:00
Michael Vetter
e408e988a7 color: set capacity in unittest case
Fix https://github.com/profanity-im/profanity/issues/1178
2019-08-23 14:54:55 +02:00
Michael Vetter
c2a565c2ec Notify trying to load 256 colour theme in incapable terminal 2019-08-23 14:24:44 +02:00
Michael Vetter
42fb1935c4 Add 256 colour info to /theme colours 2019-08-23 14:08:00 +02:00
Michael Vetter
56c77678f2 color: Include log.h 2019-08-23 14:07:41 +02:00
Michael Vetter
023e2dc387 Reset color pairs when new theme is loaded
We only need the colour pairs initialized that the theme actually uses.
It's otherwise possible that we run over the max value of initialzed
pairs.
2019-08-23 13:54:09 +02:00
Michael Vetter
df1b19ecec Reformat color.c 2019-08-23 13:48:42 +02:00
Michael Vetter
8a04496c79 Add header to color.h 2019-08-23 13:47:41 +02:00
Michael Vetter
0b9880f7a0 Use log_error() instead of g_warning() 2019-08-23 13:46:14 +02:00
Aurelien Aptel
269afa53b4 Add 256 colors support
Themes can now use color names from the xterm color name list [1].

1: https://jonasjacek.github.io/colors/
2019-08-23 13:25:45 +02:00
Michael Vetter
ab60a61fb9 omemo: use lower case to log info 2019-08-23 10:18:20 +02:00
Michael Vetter
976c2ec524 Fix typo in OMEMO materials log 2019-08-23 10:14:04 +02:00
Michael Vetter
d43bd8f253 Add comment about dead assignment in callback_add_timed 2019-08-23 10:13:45 +02:00
Michael Vetter
62103665e2 Remove unused code in cmd_room() about win num
There is actually no reason to get the window number here.
2019-08-23 10:04:54 +02:00
Michael Vetter
dacbe25d93 Remove duplicate code in roster_update
Part of what `roster_update()` does manually is actually done in
`roster_change_name()`.
2019-08-23 09:50:53 +02:00
Michael Vetter
13088e0a1a Use fixed email instead of PACKAGE_BUGREPORT 2019-08-23 09:40:54 +02:00
Holger Weiß
3228ab47d3 Don't render (all) delayed messages as MUC history
Double-check that a <delay/> tag on a groupchat message was actually
added by the MUC service (rather than the sending client) before
assuming it was received from the MUC history.

Fixes #1173.
2019-08-20 17:51:26 +02:00
Michael Vetter
d8d6aa4b88
Merge pull request #1167 from profanity-im/feature/specify-config-file
Possibility to specify alternative config file
2019-08-02 16:22:12 +02:00
Michael Vetter
10ca3e8c31 Possibility to specify alternative config file
Introduce `profanity -c` to specify an alternative config file.
2019-08-02 15:55:47 +02:00
Michael Vetter
25501a5d8a Improve sv_ev_roster_received() last activity check
We don't need to do all the timing stuff if last activity is disabled
anyways.
2019-08-02 15:52:49 +02:00
Michael Vetter
5d711639b0
Merge pull request #1166 from profanity-im/fix/1165-subscribed-msg
Don't print subscribed message if contact is already in roster
2019-08-02 12:48:01 +02:00
Michael Vetter
658e36a066 Add 'save' command to save preferences
Most applications have an 'apply changes' button. This makes testing
easier too.

Implement https://github.com/profanity-im/profanity/issues/1164
2019-08-02 10:23:13 +02:00
Michael Vetter
53c3115976 Don't print subscribed message if contact is already in roster
This occured with a user running Cisco Jabber. It seems this server
sends repeated presence subscribed stanzas. And although I find this
strange according to RFC this seems to be ok.

So let's filter them and only display in the console output and to the
log. But don't open seperate windows.

Fix https://github.com/profanity-im/profanity/issues/1165
2019-08-01 20:48:23 +02:00
Michael Vetter
ad0a1efd8c
Merge pull request #1163 from paulfariello/hotfix/command-exec
Fix memleak in /cmd exec
2019-07-30 13:50:25 +02:00
Paul Fariello
b3e59e1fb6 Fix memleak in /cmd exec 2019-07-30 13:35:08 +02:00
Michael Vetter
1ec87ffd8f
Merge pull request #1161 from profanity-im/fix/omemo-leak
Fix memleaks in OMEMO
2019-07-30 11:22:41 +02:00
Paul Fariello
5e61bc08dd Fix command form submit
Command form userdata were freed by iq_id_handler.
We should now free the command ourself.
2019-07-30 10:22:57 +02:00
Michael Vetter
1b2e71faac Fix memleak in save_identity()
I don't see a reason for strdupping here.
2019-07-23 08:34:46 +02:00
Michael Vetter
a9db705faa Fix potential leak in omemo_untrust() 2019-07-23 08:34:46 +02:00
Michael Vetter
fade378fee Dont use not needed strdup() in save_identity()
I don't see a reason for strdupping here.
2019-07-23 08:34:46 +02:00
Michael Vetter
bb08c7270d Make sure result is always set for otr_get_policy() 2019-07-23 08:03:39 +02:00
Michael Vetter
41bf7f4b22
Merge pull request #1160 from profanity-im/fix/1159-groupaddsegfault
Fix segfault in group add/remove command
2019-07-22 20:16:27 +02:00
Michael Vetter
9f0a40819f Fix memleak in roster_change_name() 2019-07-22 15:37:41 +02:00
Michael Vetter
41b54a5c14 Fix 3 leaks in cmd_funcs 2019-07-22 15:26:32 +02:00
Michael Vetter
27952cb16c Fix several memleaks im cmd_ac.c
Exiting without freeing in some cases.
2019-07-22 14:59:20 +02:00
Michael Vetter
46ddf2c2f4 Fix memleak in roster_remove
strdup() is not needed here but will actually lead to a memleak.
2019-07-22 14:47:45 +02:00
Michael Vetter
41267ae1c5 Fix memory leak in roster_update()
current_name should not be const and should be freed.
2019-07-22 14:42:43 +02:00
Michael Vetter
e540ccd50e Remove dead assignments 2019-07-22 14:27:14 +02:00
Michael Vetter
137d128af2 Remove unused assignments 2019-07-22 14:16:10 +02:00
Michael Vetter
e75cc41164 Fix double initialization of loop iterator 2019-07-22 14:02:33 +02:00
Michael Vetter
16174727f4 Guard against arg being NULL in cmd_funcs
This should actually never happen because we have the mechanism that
checks the commands. But let's do it in case we break something in that
mechanism and to make clang happy.

Fixes clangs: 'Argument with 'nonnull' attribute passed null'
2019-07-22 13:47:52 +02:00
Michael Vetter
d004891a29 Reduce scope of num in ui_print_system_msg_from_recipient() 2019-07-22 13:25:52 +02:00
Michael Vetter
fa27ab9561 Fix segfault in group add/remove command
Also regarding destructor.
Fix https://github.com/profanity-im/profanity/issues/1159
2019-07-22 11:54:05 +02:00
Michael Vetter
4a0fa1cf9e
Merge pull request #1154 from optmzr/issue-1099
Always check for directory changes with sendfile auto completion
2019-07-20 19:36:59 +02:00
William Wennerström
0c10a699f2
Always check for directory changes with sendfile auto completion
Instead of only checking for files when 'last_directory' has changed, do
it every time.

Add autocomplete_update function that updates the items while retaining
last_found and search_str.

Fixes #1099
2019-07-20 10:38:22 +02:00
Michael Vetter
d3828cf24e Fix segfault in block command
Another case of double free() due to new destructor.

Fixes https://github.com/profanity-im/profanity/issues/1156
2019-07-19 12:38:33 +02:00
Michael Vetter
c07d533ec1 Fixup for last commit 2019-07-12 11:11:45 +02:00
Michael Vetter
68b6deefbf Fix segfault in iq_{submit,cancel}_command_config
Taken care of by the destructor.
2019-07-12 10:57:07 +02:00
Michael Vetter
04988ab4ba Fix segfault in /cmd exec
Test for correct number of arguments before using argument.
2019-07-12 10:36:17 +02:00
Michael Vetter
ad41959cc6
Merge pull request #1150 from paulfariello/hotfix/omemo-memleaks
Hotfix/omemo memleaks

Regards https://github.com/profanity-im/profanity/issues/1131
2019-07-11 16:19:31 +02:00
Michael Vetter
f32827d70d Fix some more potential double frees
Regards https://github.com/profanity-im/profanity/issues/1148
2019-07-11 16:15:57 +02:00
Paul Fariello
c22df13d95 Dirty fix libgcrypt memleak 2019-07-11 14:25:42 +02:00
Paul Fariello
b7144d82fe Enable secure memory in gcrypt initialisation 2019-07-11 11:01:07 +02:00
Paul Fariello
b110da9a92 Fix various OMEMO memleaks 2019-07-10 17:32:23 +02:00
Michael Vetter
eb14ae5f03 Fix jump depending on uninit. value in statusbar 2019-07-10 12:55:49 +02:00
Michael Vetter
6c8e567328 Reduce codelines in form.c
Let's use calloc instead of malloc and then setting almost all fields to
NULL.
2019-07-10 12:53:45 +02:00
Michael Vetter
a8b3de7016 Fix double free in roster_process_pending_presence
This is taken care of now in the destructor _pendingPresence_free().
2019-07-10 12:08:09 +02:00
Michael Vetter
38edc1c325 Add destructor for roster_pending_presence
Fix:
```
==18682== 408 bytes in 17 blocks are definitely lost in loss record
3,279 of 3,632
==18682==    at 0x483677F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==18682==    by 0x42F602: roster_update_presence (roster_list.c:129)
==18682==    by 0x448AA3: sv_ev_contact_online (server_events.c:906)
==18682==    by 0x43D2BA: _available_handler (presence.c:674)
==18682==    by 0x43C81B: _presence_handler (presence.c:398)
==18682==    by 0x5AF118E: handler_fire_stanza (handler.c:124)
==18682==    by 0x5AEDBDA: _handle_stream_stanza (conn.c:1253)
==18682==    by 0x5AFA43E: _end_element (parser_expat.c:190)
==18682==    by 0x6818AA4: doContent (xmlparse.c:2977)
==18682==    by 0x681A3AB: contentProcessor (xmlparse.c:2552)
==18682==    by 0x681D7EB: XML_ParseBuffer (xmlparse.c:1988)
==18682==    by 0x681D7EB: XML_ParseBuffer (xmlparse.c:1957)
==18682==    by 0x5AF0A63: xmpp_run_once (event.c:255)
==18682==    by 0x432E5D: connection_check_events (connection.c:104)
==18682==    by 0x4323B3: session_process_events (session.c:255)
==18682==    by 0x42C097: prof_run (profanity.c:128)
==18682==    by 0x4B25B9: main (main.c:172)
```
2019-07-09 16:04:27 +02:00
Michael Vetter
89d8fc846e Fix double free in room id handler
Free is done in destructor now.
Regards https://github.com/profanity-im/profanity/issues/1148
2019-07-09 09:47:35 +02:00
Michael Vetter
7af85d0fe0 Fix double free in omemo_start_device_session_handle_bundle()
omemo_key_free() was called to free the key.
It free the key->data too. But in same cases this was not set  yet. So
we need to set the data to NULL (or use calloc) at initialization so
that omemo_key_free() only frees it if it was actually allocated.

Regards https://github.com/profanity-im/profanity/issues/1148
2019-07-08 16:36:05 +02:00
Michael Vetter
b3bb62dcbd Fix double free regarding iq handlers 2019-07-08 15:58:40 +02:00
Michael Vetter
6355272091
Merge pull request #1146 from profanity-im/fix/omemoleaks-autocompl
Fix several OMEMO related leaks
2019-07-04 18:01:59 +02:00
Michael Vetter
9aad2aa487 Free iq_id_handlers correctly
so far only the key part was freed. We also need to free the actual
handler.

Fix:
```
==21171== 1,128 bytes in 47 blocks are definitely lost in loss record
3,476 of 3,670
==21171==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21171==    by 0x434248: iq_id_handler_add (iq.c:265)
==21171==    by 0x4B122E: omemo_devicelist_request (omemo.c:46)
==21171==    by 0x4AC411: omemo_start_session (omemo.c:409)
==21171==    by 0x4AC37C: omemo_start_sessions (omemo.c:396)
==21171==    by 0x447881: sv_ev_roster_received (server_events.c:189)
==21171==    by 0x444019: roster_result_handler (roster.c:312)
==21171==    by 0x433FC2: _iq_handler (iq.c:202)
==21171==    by 0x5AF118E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==21171==    by 0x5AEDBDA: ??? (in /usr/lib64/libmesode.so.0.0.0)
==21171==    by 0x5AFA43E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==21171==    by 0x6818AA4: ??? (in /usr/lib64/libexpat.so.1.6.8)
==21171==    by 0x681A3AB: ??? (in /usr/lib64/libexpat.so.1.6.8)
==21171==    by 0x681D7EB: XML_ParseBuffer (in
/usr/lib64/libexpat.so.1.6.8)
==21171==    by 0x5AF0A63: xmpp_run_once (in
/usr/lib64/libmesode.so.0.0.0)
==21171==    by 0x432E5D: connection_check_events (connection.c:104)
==21171==    by 0x4323B3: session_process_events (session.c:255)
==21171==    by 0x42C097: prof_run (profanity.c:128)
==21171==    by 0x4B2627: main (main.c:172)
```
2019-07-04 14:25:53 +02:00
Paul Fariello
c0e8f72276 Fix plaintext private message handling 2019-07-04 14:02:42 +02:00
Michael Vetter
482138feff Free key on error in omemo_start_device_session_handle_bundle()
Fix:
```
==20561== 32 bytes in 1 blocks are definitely lost in loss record 1,467
of 3,678
==20561==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20561==    by 0x4B16C9: omemo_start_device_session_handle_bundle
(omemo.c:167)
==20561==    by 0x43405E: _iq_handler (iq.c:214)
==20561==    by 0x5AF118E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x5AEDBDA: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x5AFA43E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x6818AA4: ??? (in /usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x681A3AB: ??? (in /usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x681D7EB: XML_ParseBuffer (in
/usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x5AF0A63: xmpp_run_once (in
/usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x432E5D: connection_check_events (connection.c:104)
==20561==    by 0x4323B3: session_process_events (session.c:255)
==20561==    by 0x42C097: prof_run (profanity.c:128)
==20561==    by 0x4B260D: main (main.c:172)
```
2019-07-04 11:55:53 +02:00
Michael Vetter
e3443f5c9a Rework omemo_start_device_session_handle_bundle exit
In some conditions we just returned without freeing allocated variables.

Should fix following valgrind reported leak:

```
==17941== 19 bytes in 1 blocks are definitely lost in loss record 613 of
3,674
==17941==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17941==    by 0x5BB0DAA: strdup (strdup.c:42)
==17941==    by 0x4B1592: omemo_start_device_session_handle_bundle
(omemo.c:126)
==17941==    by 0x43405E: _iq_handler (iq.c:214)
==17941==    by 0x5AF118E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==17941==    by 0x5AEDBDA: ??? (in /usr/lib64/libmesode.so.0.0.0)
==17941==    by 0x5AFA43E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==17941==    by 0x6818AA4: ??? (in /usr/lib64/libexpat.so.1.6.8)
==17941==    by 0x681A3AB: ??? (in /usr/lib64/libexpat.so.1.6.8)
==17941==    by 0x681D7EB: XML_ParseBuffer (in
/usr/lib64/libexpat.so.1.6.8)
==17941==    by 0x5AF0A63: xmpp_run_once (in
/usr/lib64/libmesode.so.0.0.0)
==17941==    by 0x432E5D: connection_check_events (connection.c:104)
==17941==    by 0x4323B3: session_process_events (session.c:255)
==17941==    by 0x42C097: prof_run (profanity.c:128)
==17941==    by 0x4B2610: main (main.c:172)
```
2019-07-04 11:46:32 +02:00
Michael Vetter
0410802753 Free omemo_ctx.device_list_handler 2019-07-04 10:47:50 +02:00
Michael Vetter
d0047c8376 Dont initialize omemo autocompleter twice
We already do this in omemo_init() no need to do it again in
omemo_on_connect().
2019-07-04 10:38:24 +02:00
Michael Vetter
199162b11a Add omemo_close function
We call omemo_init() when starting profanity and should have an
omemo_close() at exit.

For now we free the fingerprint autocompleter in there.

Fixes valgrind:
```
==13226== 24 bytes in 1 blocks are definitely lost in loss record 2,855
of 6,958
==13226==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==13226==    by 0x48AD39: autocomplete_new (autocomplete.c:57)
==13226==    by 0x4AB89F: omemo_init (omemo.c:127)
==13226==    by 0x42C283: _init (profanity.c:206)
==13226==    by 0x42BFF3: prof_run (profanity.c:98)
==13226==    by 0x4B25E6: main (main.c:172)
```

Regards https://github.com/profanity-im/profanity/issues/1131
2019-07-04 10:30:56 +02:00
Michael Vetter
4a6b1665f3 Use correct jid variable 2019-07-03 15:28:46 +02:00
Michael Vetter
f504a02167 Define goto out in _private_chat_handler() 2019-07-03 15:27:31 +02:00
Michael Vetter
19902e8e21 Set plain message in _private_chat_handler
In case that plain is NULL we need to copy over from body.

Fix https://github.com/profanity-im/profanity/issues/1144
2019-07-03 15:16:19 +02:00
Michael Vetter
ad9263520e Show MUC history on intentional reconnect
Small bug caused by 13675fb and ce5a4ed.
Fix https://github.com/profanity-im/profanity/issues/1142
2019-07-03 09:19:24 +02:00
Paul Fariello
f081766913 Mark messages received from a session as trusted 2019-06-25 18:43:15 +02:00
Paul Fariello
45e8467231 Fix a segfault when carbon has no body 2019-06-21 16:49:52 +02:00
Paul Fariello
db8f32c049 Fix handling of encrypted carbons 2019-06-21 15:52:24 +02:00
Paul Fariello
498b75afa9 Don't highlight cleartext message as untrusted 2019-06-21 15:50:41 +02:00
Paul Fariello
ac96a6951d Fix segfault when receiving messages without ID 2019-06-21 12:03:08 +02:00
Paul Fariello
a444137e66 Fix NULL pointer when handling non encrypted message in MUC 2019-06-21 11:34:36 +02:00
Paul Fariello
f831f65737 Rename prof_message_t into ProfMessage 2019-06-20 14:30:45 +02:00
Paul Fariello
9482ce6168 Set foreground color for untrusted messages 2019-06-20 14:30:45 +02:00
Paul Fariello
44d16e9141 Add prof_message_t to wrap all message attributes
Probably missing copy of body to plain in carbon and privmessage.
Only covers the incoming message path because goal is OMEMO decryption
of untrusted message.
Cover some of the log functions but not all.
2019-06-20 14:30:42 +02:00
Paul Fariello
3bb3cc625d Use flags in xmmp/message.c for encryption and trust 2019-06-20 14:30:37 +02:00
Paul Fariello
a650ecc67d Add trusted state after OMEMO decryption
Use it to print message on red background if not trusted.
2019-06-20 14:29:55 +02:00
Paul Fariello
2604786cb6 Decrypt all incoming OMEMO msg
Trust all key as long as it's for reading. This code isn't multithread
safe.
2019-06-20 14:29:55 +02:00
Michael Vetter
7ca8ec3e6b _bookmark_destroy: follow normal logic 2019-06-20 12:37:32 +02:00