1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00
Commit Graph

1219 Commits

Author SHA1 Message Date
Michael Vetter
44343a5c37 avatar: make _avatar_metadata_handler safer 2021-03-25 16:34:20 +01:00
Michael Vetter
b584a1ecd0 ox: make _ox_public_key_result safer 2021-03-25 16:30:19 +01:00
Michael Vetter
10df93ee3e ox: guard printing of fingerprint 2021-03-25 16:25:18 +01:00
Michael Vetter
fb81b80499 ox: improve error log in _ox_metadata_result 2021-03-25 16:24:07 +01:00
Michael Vetter
31a78e2629 ox: add logging prefix 2021-03-25 16:22:47 +01:00
Michael Vetter
f81ed759f5 stanza: guard mallocs
If this happens we have more serious problems :-)
But anyways..
2021-03-25 16:14:40 +01:00
Michael Vetter
d23c3dd065 stanza: simplify stanza_get_muc_destroy_alternative_room 2021-03-25 15:59:48 +01:00
Michael Vetter
caa2c7afd0 stanza: replae strcmp with g_strcmp0
since its NULL safe
2021-03-25 15:55:18 +01:00
Michael Vetter
1f96e14ce7 message: simplify _handle_headline 2021-03-25 15:43:57 +01:00
Michael Vetter
b2a02424ed message: make _receipt_request_handler safer 2021-03-25 15:38:48 +01:00
Michael Vetter
099260a4e3 message: make _handle_receipt_received safer 2021-03-25 15:37:54 +01:00
Michael Vetter
2236242407 message: make _handle_groupchat safer 2021-03-25 15:36:17 +01:00
Michael Vetter
ca9c946ddc message: simplify _handle_conference 2021-03-25 15:33:30 +01:00
Michael Vetter
2601fc5571 message: make _handle_form safer 2021-03-25 15:27:59 +01:00
Michael Vetter
b1bd1ecca8 message: make _message_handler safer 2021-03-25 15:26:16 +01:00
Michael Vetter
11382a8bf3 mesage: make _handle_ox_chat safer
And on the way fix a memleak
2021-03-25 15:20:53 +01:00
Michael Vetter
8a6d256fc1 message: make _handle_chat safer 2021-03-25 15:07:09 +01:00
Michael Vetter
ee87e5b036 message: make _handle_muc_private_message safer 2021-03-25 15:03:35 +01:00
Michael Vetter
d2dc440535 message: fix potential segfault in _receipt_request_handler 2021-03-25 11:56:38 +01:00
Michael Vetter
e396e863dd message: safeguard _handle_receipt_received
This shouldnt be necessary since we check for the receipt outside
alreayd. Let's be on the safe side though in case code gets changed
later.
2021-03-25 11:54:59 +01:00
Michael Vetter
9cfe5ec787 message: reorder _handle_groupchat 2021-03-25 11:51:42 +01:00
Michael Vetter
96b228728e message: fix possible segfault in _handle_conference 2021-03-25 11:43:42 +01:00
Michael Vetter
f21a99eaf8 message: fix possible segfault in _handle_muc_user 2021-03-25 11:38:22 +01:00
Michael Vetter
e656bdb83c message: fix possible segfault in _message_handler 2021-03-25 11:34:14 +01:00
Michael Vetter
fde0a0d1c6 Add support to register with a room
`/affiliation register` can now be used to register a nickname with a
MUC.

Tested with a server without forms. Couldn't find a server which
supports forms yet.

Implements https://github.com/profanity-im/profanity/issues/1210
2021-03-25 11:05:58 +01:00
Michael Vetter
ebb1be9e58 form.c: fix memleak in form_tag_exists 2021-03-17 16:18:56 +01:00
Michael Vetter
5cec47c86a Add support to approve MUC voice requests
A form will open. One can then use `/field4 on` `/form submit`.

Implements https://github.com/profanity-im/profanity/issues/1507
2021-03-17 16:16:59 +01:00
Thorben Günther
ec6f9df486
MUC: Add voice request
closes https://github.com/profanity-im/profanity/issues/1211
2021-03-12 14:57:00 +01:00
Michael Vetter
a7ecda7773
Merge pull request #1501 from xenrox/change-password
Add command to change password of logged in user
2021-03-11 18:18:03 +01:00
Thorben Günther
b0aea2bcff
Add command to change password of logged in user 2021-03-11 17:42:53 +01:00
Maximilian Wuttke
e217ed0b79 Update to the newest version of XEP 0363 (HTTP Upload)
Main changes:

1. Attributes instead of tags
2. Read the optional <header> tags and send them in the HTTP PUT header:

   * Authorization
   * Cookie
   * Expires

Co-authored-by: Martin Dosch <martin@mdosch.de>
2021-03-11 17:11:22 +01:00
Maximilian Wuttke
2b1ada7722 [OMEMO]: Fix bundle publishing
Use the following options in `omemo_bundle_publish()`:

- "pubsub#persist_items" = "true"
- "pubsub#access_model" = "open"

The same options are also used in Gajim.

I've tested this on two different servers. The bundle was successfully
added as a new PEP node. Test cases:

1. Normal use on my main account
2. Log in into a fresh tesst account on a different server
3. `/omemo clear_device_list`. In this case, the client(s) may have to
   be restarted.

Note: In `_omemo_bundle_publish_result`, there's a route that is taken
when the bundle publish stanza failed. In this case, the node is
configured manually, i.e. the access_model is set to 'open'. I have
manually tested this case, but this case didn't naturally occur for me.

Note: The option "pubsub#max_items=max" is REQUIRED for the bundle
publication, as per XEP-0384. However, this is not done in other clients
(I've checked the source code of Gajim and Conversations), and it is
also not supported by Prosody. Cf. <https://github.com/xsf/xeps/pull/988>.
2021-03-09 17:48:29 +01:00
Maximilian Wuttke
68469149cd Logging [OMEMO]
Also "handle" some errors in `_omemo_bundle_publish_configure` if the
stanzas can't be found
2021-03-09 17:47:43 +01:00
Maximilian Wuttke
4124856100 Variadic version of stanza_attach_publish_options 2021-03-09 17:47:37 +01:00
Maximilian Wuttke
8481698705 Logging [OMEMO] 2021-03-09 17:47:27 +01:00
Stefan
637c2c2d62 Logging [CONNECTION] 2021-03-09 17:47:22 +01:00
Michael Vetter
69e923df3b Remove forgotten debug line 2021-02-15 09:58:37 +01:00
Michael Vetter
1435c7ae14 Use correct time for MAM messages
We need the delay value from the <forward> element.

Regards https://github.com/profanity-im/profanity/issues/660
2021-02-04 21:13:31 +01:00
Michael Vetter
c2ec3e7033 Enable error logging on MAM RSM 2021-01-28 14:44:53 +01:00
Michael Vetter
840238b126 Get MAM from last 7 days
Probably should make this configurable later.
2021-01-28 14:44:53 +01:00
Michael Vetter
d3303517f7 MAM: Request more pages via RSM
Send another request with same jid and last id we got.
2021-01-28 14:44:53 +01:00
Michael Vetter
6e1e01dbb8 Adapt MAM RSM code to latest functions
Some functions changed in the meantime.
stanza_get_child_by_name_and_ns() got dropped and
xmpp_stanza_get_child_by_name_and_ns() from newer libstrophe is used.
2021-01-28 14:44:53 +01:00
Michael Vetter
db65255a5a wip: add rsm after we get the first couple of mam messages 2021-01-28 14:44:53 +01:00
Michael Vetter
69e35e86b2 mam: Use correct ID in rsm handler
Thanks to DebXWoody for the help.
2021-01-28 14:44:53 +01:00
Michael Vetter
d06ca64098 mam: fix logging message 2021-01-28 14:44:53 +01:00
Michael Vetter
014e03c72e Start working on MAM RSM to get more pages
Regards https://github.com/profanity-im/profanity/issues/660
2021-01-28 14:44:35 +01:00
Michael Vetter
8c08e64f37 Update copyright 2021-01-08 16:36:30 +01:00
Michael Vetter
881b99c062 Remove not needed include 2020-12-16 14:46:01 +01:00
Michael Vetter
a94378f206 Fix various typos 2020-12-10 09:24:32 +01:00
Michael Vetter
35aecd425f Declare counter var inside loop
We require c99/gnu99 anyways.
2020-11-09 11:33:33 +01:00
Michael Vetter
3b3c9bf4d5 Print all error stanzas
Regards https://github.com/profanity-im/profanity/issues/1435

So far we didn't print the error if it contained `<error
type="cancel">`. It appears that the code always thought this is a
service-not-available (so one is either blocked or the account doesn't
exist) and printed `Recipient not found`.

But there can be other errors as well. Like in above mentioned issue
`not-allowed`.

Let's just print the text.

In case of the cancel type we still remove the jid from the chat
sessions. I'm not entirely sure whether this needs to be done in other
cases too.
2020-10-30 15:09:40 +01:00
DebXWoody
15f45fcfe1 Fixed Date format for MAM request
Using g_date_time_new_now_utc instead of g_date_time_new_now_local
Using g_date_time_format(timestamp, "%FT%TZ") instead of "%FT%T%:::z"

Edit:
DebXWoody created this patch because ejabberd returned an error with the
old date format.
2020-10-28 09:06:49 +01:00
Dmitry Podgorny
3a86b997ca xmpp/bookmark: don't use uninitialised field
When a bookmark is created with '/bookmark add' command,
ext_gajim_minimize remains uninitialised in new bookmark object and
is read further in _send_bookmarks().

Initialise the field with 0.

Fixes #1432.
2020-10-19 00:00:00 +03:00
Philipp Klaus Krause
6a276e74e3 Since the string from strerror should never be modified, use const. 2020-10-14 09:52:26 +02:00
Michael Vetter
4d4c094b5f Enable _handle_ox_chat() payload/body decryption
This part of the code was waiting for xmpp_stanza_new_from_string() from
libstrophe 0.10.0.
2020-10-09 09:38:47 +02:00
Michael Vetter
17b1b431f5 Replace stanza_get_child_by_name_and_ns with xmpp_stanza_get_child_by_name_and_ns
Replace our own stanza_get_child_by_name_and_ns() with the upstreamed
xmpp_stanza_get_child_by_name_and_ns() provided by the new
libstrophe/libmesode 0.10.0.
2020-09-30 19:41:08 +02:00
Michael Vetter
0a9200e268 Require libstrophe/libmesode 0.10.0 2020-09-30 19:30:40 +02:00
Dmitry Podgorny
7553676b40 Fix memory leak in _handle_chat()
jid_create() for attribute "to" was called twice and the 1st object was
lost.
2020-08-07 00:47:45 +03:00
Michael Vetter
8852db03d6 Parse stanza-id
Add stable stanza IDs to ProfMessage struct.

We parse this for 1:1 messages (MUC needs to be done too).

<stanza-id> for live messages
<result id="x"> for MAM messages

Regards MAM: https://github.com/profanity-im/profanity/issues/660
Regards Stable IDs: https://github.com/profanity-im/profanity/issues/1207
2020-07-23 14:21:27 +02:00
Michael Vetter
d7b7f54782 ox review: Use english not german 2020-07-10 13:41:48 +02:00
DebXWoody
0552e50c78 OX: XEP-0373: OpenPGP for XMPP - Version 0.5.0 (2020-06-19)
Discovering Public Keys via PEP

* 4.3 Discovering Public Keys of a User
* 4.4 Requesting Public Keys

* Import Public Keys into GnuPG's local keyring.

Issue: #1331
2020-07-10 13:40:00 +02:00
Michael Vetter
a2726b6a7d Apply coding style 2020-07-07 14:18:57 +02:00
Michael Vetter
bddbfa58c0 OX: Fix tests
Fix:
```
/usr/bin/ld: src/xmpp/ox.o: in function `ox_announce_public_key':
src/xmpp/ox.c:90: undefined reference to `p_ox_gpg_readkey'
```
2020-07-07 14:07:38 +02:00
Michael Vetter
a4cadf78fa Revert "Apply coding style"
This reverts commit 9b55f2dec0.

Sorting the includes creates some problems.
2020-07-07 13:53:30 +02:00
Michael Vetter
9b55f2dec0 Apply coding style
Regards https://github.com/profanity-im/profanity/issues/1396
2020-07-07 09:43:28 +02:00
DebXWoody
5a17957253 OX: Announce public key on PEP
src/pgp/gpg.c:p_ox_gpg_readkey

Used to read a public key from a file. The function will return the fingerprint
of the file and the base64 encoded key.

src/xmpp/ox.[hc]

ox_announce_public_key(const char* const filename) can be called from the /ox
announce <filename> command. The key within the file will be pushed on PEP and
the Metadata node will be set.

Issue: #1331
2020-07-06 13:19:18 +02:00
Michael Vetter
bf170d6c91 Merge branch 'omemofix' 2020-07-04 17:38:44 +02:00
DebXWoody
54667c022f Messages are not shown in ChatSecure
In 0.9.x we fixed an issue, because OMEMO devices should be defined in "item"
with id "current". This should work, but it won't work if there is no "current".
If there is no "current" we will just use the first item.

Issue #1384
2020-07-04 17:38:30 +02:00
Michael Vetter
aecbeff8ba message.c: Use message->to_jid instead of to_jid
This one will always be set.
2020-07-03 18:04:07 +02:00
Michael Vetter
b1343cd3ac message.c: _handle_carbons() check from field outside of function
So that we don't have to pass the wrapping stanza and can handle
the error nicer.
2020-07-03 17:55:15 +02:00
Michael Vetter
896e6c4e87 message.c: Dont duplicate code in _handle_carbon and _handle_chat
Trying to simplify the conditions so we don't have duplicate code
in both of those functions.
2020-07-03 17:51:42 +02:00
Michael Vetter
8ce299838d message.c: Remove from/to setting out of condition
Since its done in both cases.
2020-07-03 16:38:05 +02:00
Michael Vetter
0412ec9662 message.c: Small code improvements 2020-07-03 16:26:33 +02:00
Michael Vetter
c66d3c6389 message.c: Put XEP-0085 code in helper function 2020-07-03 16:17:18 +02:00
Michael Vetter
14f33e54f6 Change formatting 2020-07-03 12:35:48 +02:00
Michael Vetter
8d8ef675cd handle_headline(): Free text correctly 2020-07-03 12:05:46 +02:00
Stefan Kropp
3640900cf6 Handle headline stanza
Authored by DebXWoody in:
https://github.com/profanity-im/profanity/pull/1369

Regards: https://github.com/profanity-im/profanity/issues/1366

Since I'm in the process of cleaning up message.c I take this now
so he doesn't have to rebase.

I also omitted the _handle_normal() case since I'm not sure that would
be correct.

Probably will be addressed again when continuing the cleanup.
2020-07-03 12:02:41 +02:00
William Wennerström
d5aae08c41
Fix messages with receipt request not displayed
Messages from Conversations contains:
  <request xmlns='urn:xmpp:receipts'/>

And would not be displayed in Profanity as it never reached
_handle_chat(..).
2020-07-02 20:50:26 +02:00
Michael Vetter
83ed9ba24b message.c: Put plugin handler code in helper function 2020-07-02 17:53:28 +02:00
Michael Vetter
6be5b51a46 message.c: Log invalid message type
So far we logged when we receive a message without a type. Which is
actually quite common and makes no sense.
2020-07-02 17:47:07 +02:00
Michael Vetter
46a00317ee message.c: Check for message type
RFC 6121 allows only few types.
So we can also remove that check in _handle_chat().
2020-07-02 17:40:58 +02:00
Michael Vetter
19d9e80a79 message.c: Remove handled cases form _handle_chat()
Both cases are tested before entering that function.
2020-07-02 17:32:14 +02:00
Michael Vetter
d9cfa2e48a message.c: Break out of _message_handler() after handling code
AFAIK it can only be one.
Except at STANZA_NS_MUC_USER which is used in several cases.
2020-07-02 17:31:56 +02:00
Michael Vetter
ad3dd72325 Add HEADLINE stanza define 2020-07-02 17:17:28 +02:00
Michael Vetter
b14b711492 message.c: Parse incoming message stanzas according to type 2020-07-02 17:15:42 +02:00
Michael Vetter
728cb55b68 message.c: Add pubsub helper function 2020-07-02 16:48:57 +02:00
Michael Vetter
f2b415079a message.c: Add XEP information 2020-07-02 16:37:20 +02:00
Michael Vetter
1f50647865 message.c: Add my copyright 2020-07-02 15:22:58 +02:00
Michael Vetter
3350139ed0 message.c: Make several functions static 2020-07-02 15:21:54 +02:00
Michael Vetter
10190b5fb0 message.c: Adjust function formatting 2020-07-02 15:20:17 +02:00
Michael Vetter
e5ac12afa6 Remove prefs_free_string()
It just does a free.
Related to b580b9ef11
2020-07-02 11:34:12 +02:00
Michael Vetter
8de6a7bfb0 And ifdefs around new OX functions
Fix for some build cases introduced in 2c94ee5a88
Fix https://github.com/profanity-im/profanity/issues/1376
2020-06-30 11:10:27 +02:00
DebXWoody
2c94ee5a88 Feature request - XEP-0373: OpenPGP for XMPP (OX)
Basic implementation of XEP-0373: OpenPGP for XMPP.
https://xmpp.org/extensions/xep-0373.html

Command /ox

Issue: #1331
2020-06-29 19:05:41 +02:00
Dmitry Podgorny
409bbd6f2d Fix possible segfault in xmpp/message.c
Check for pointer to be NULL before dereferencing it.
2020-06-16 17:52:01 +03:00
Michael Vetter
914c6752dd Fix reading/writing linked files
"base" was not really base but the filename :-)

Fix https://github.com/profanity-im/profanity/issues/1362
2020-06-13 15:02:43 +02:00
Dmitry Podgorny
424918c5ed Make legacy auth optional
Some systems don't provide recent libstrophe releases. When older
version of libstrophe is detected, don't build legacy auth support.

To simplify this patch, report about unsupported legacy auth and
keep commands option as is.
2020-06-11 02:51:07 +03:00
Dmitry Podgorny
ac410445af Add option for legacy authentication
New options:
  /connect <account> [auth default|legacy]
  /account <account> set auth default|legacy

Fixes #1236.
2020-06-05 11:37:51 +03:00
Pierre Mazière
d92c576aa5 Get output and error streams from the command spawned by external_call()
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2020-06-03 13:09:29 +02:00
Michael Vetter
e19bf0e303 Merge branch 'bugfix/1329' 2020-05-29 10:29:20 +02:00
Michael Vetter
24e8243a98 _omemo_receive_devicelist() use if/else 2020-05-29 10:28:41 +02:00
Michael Vetter
8d9cbef1e3
Merge pull request #1343 from DebXWoody/bugfix/1333
Incoming iq stanza - Reset the autoping timer
2020-05-29 10:21:51 +02:00
Michael Vetter
d4692b1b2d Fix carbon logging
Regards https://github.com/profanity-im/profanity/issues/1342
2020-05-27 22:06:04 +02:00
Michael Vetter
de8975c008 Add and use connection_get_barejid()
Instead of connection_get_fulljid() and then creating a Jid from it.
2020-05-25 13:04:19 +02:00
Michael Vetter
a2af4c3184 Fix memleak in bookmark minimize
Introduced in 36f2569e53
2020-05-24 13:35:09 +02:00
DebXWoody
b882fd495a
OMEMO - Request only "current" item
NOTE: as per XEP-0060 §12.20, it is RECOMMENDED for the publisher to specify an
ItemID of "current" to ensure that the publication of a new item will overwrite
the existing item.
https://xmpp.org/extensions/xep-0384.html#devices

Issue: 1329
2020-05-23 07:41:06 +02:00
DebXWoody
3cd3bced70
Incoming iq stanza - Reset the autoping timer
A autoping is to make sure that there is still a connection between server and
client. If the application receives incoming stanza, the connection is fine.
There is no need to wait for response, if there are other incomings.

Issue: #1333 and #1315
2020-05-23 06:52:03 +02:00
Michael Vetter
c8be052ec8 Fix segfault in new bookmark feature
Fix 88c36745fe
Copy paste mistake.
2020-05-22 16:20:02 +02:00
Michael Vetter
36f2569e53 Preserve Gajims minimize flag in bookmarks
Implement https://github.com/profanity-im/profanity/issues/1326
2020-05-22 16:18:28 +02:00
Michael Vetter
88c36745fe Add option to add bookmark name
`/bookmark add|update` got `name` field.
By default localpart of JID is used (like before) but now we can set the
name ourselves.

Regards https://github.com/profanity-im/profanity/issues/697
2020-05-22 14:18:20 +02:00
Michael Vetter
fad296b79e Display bookmark name
Have field in struct and display the name in `/bookmark list`.

Regards https://github.com/profanity-im/profanity/issues/697
2020-05-22 13:56:00 +02:00
Michael Vetter
e41ae21bea Fix typing notification
With d1d0ad8d1a we set a timestamp to now
for all messages upon receival. Even if the original message didn't
contain any timestamp. So we can use the timestamp of retrieval for
logging and displaying and don't get them at each of those location
where they might differ.

This means that timestamp will never be NULL.

I don't see why we would want to check for the chat state only if
timestamp isn't there.

Probably because in XEP-0085 there is not timestamp defined.
So if it thats stanza it's not there and we can parse quicker, but there
is nothing forbidden it to be there.

Related to https://github.com/profanity-im/profanity/issues/1339
2020-05-21 12:24:03 +02:00
Michael Vetter
fc5fa62951 Create call_external() helper function 2020-05-20 10:54:58 +02:00
Michael Vetter
9c853d9f46 xep-0092: make it possible to ask servers or components for software
This adds the new `/serversoftware` command.

```
/software user@domain.org/resource
/serversoftware domain.org
```

Fix https://github.com/profanity-im/profanity/issues/1338
2020-05-14 19:13:27 +02:00
Michael Vetter
5ec1b03cbc _handle_carbons(): fix potential memleak 2020-04-21 17:11:04 +02:00
Michael Vetter
b9c384d6ca _iq_id_handler_free() dont set NULL
No effect here.
2020-04-20 16:17:09 +02:00
Michael Vetter
9e460973fa Fix potential memleak in stanza_create_caps_from_query_element()
Each of those should only occur one time. But let's make sure we only
write/alloc one time to be on the safe side.
2020-04-20 15:31:48 +02:00
DebXWoody
6268f5f0d7
OMEMO Device List only for non anonymous MUCs
Profanity request the OMEMO Device List for all members, also if the MUC is
anonymouse. If the user is Admin / Owner, the device list will be requtest.

Issue #1315
2020-04-17 19:53:34 +02:00
Michael Vetter
9be7d29f1b Don't expose upload_processes
That's actually not good practise.
Realized this when checking for multiple symbol definition in issue
mentioned below.

Regards https://github.com/profanity-im/profanity/issues/1314
2020-04-17 10:05:09 +02:00
Michael Vetter
616250b2b4 Review logging in iq.c 2020-04-14 18:53:08 +02:00
Michael Vetter
48290d3d61 Review logging for blocking.c 2020-04-14 18:32:43 +02:00
Michael Vetter
b73606cc60 Review logging in presence.c
Some stuff just floods the log file. We only need this when debugging.
Others are useless without more info.
2020-04-14 18:29:15 +02:00
Michael Vetter
18c64c0580 Free timestamp correctly
g_date_time_add_days() actually creates a new one.
2020-04-13 10:04:37 +02:00
Michael Vetter
98200ebd43 Check if server suppors MAM 2020-04-12 00:24:00 +02:00
Michael Vetter
aedecee962 Get MAM since yesterday
Later we will have several options.
Getting everything since last timestamp (if none everything at all).
Getting everything since today + configure time (1 week).

Should also have a reload all command like conversations once you
cleared the history.

All MAM messages should be written into sql db.
And then probably displayed from there so that regular history works
too.
2020-04-12 00:06:36 +02:00
Michael Vetter
dd566d8d56 MAM: Correctly display incoming MAM chat message 2020-04-11 23:56:01 +02:00
Michael Vetter
180ec2b474 Add to_jid field to ProfMessage struct
Is usefult in many cases if we want cleaner code.
Hope this edit didn't break anything though ;-)
2020-04-11 17:11:53 +02:00
Michael Vetter
38273fef5c First test with receiving MAM 2020-04-11 16:05:14 +02:00
Michael Vetter
f3b8cc407d _handle_chat: return if no 'from'
Let's not crash :-)
2020-04-11 16:05:14 +02:00
Michael Vetter
e878b6d266 Don't crash if we get a message without from or type
MAM messages don't have a type nor a from.
If we detect a message without type let's log it and exit without
continuing to try to parse it.

Otherwise we go into _handle_chat() and crash on the no from.
2020-04-11 16:05:14 +02:00
Michael Vetter
fe9b520c42 First MAM test
Send a request (which we can't handle yet) :-)

Regards https://github.com/profanity-im/profanity/issues/660
2020-04-11 16:05:14 +02:00
Dmitry Podgorny
44377c6a5c Fix use-after-free in stanza_create_caps_from_query_element()
The function creates a form to find such strings as software, os, etc.
It remembers the strings allocated by form_create() and use them below
in caps_create(). The issue is that the form is destroyed before and as
result the strings are freed too.

As solution, allocate own copy of strings.
2020-04-09 15:22:11 +03:00
Michael Vetter
37c2bd9334 Fix comment 2020-04-06 22:34:45 +02:00
Michael Vetter
6218a53727 Add hint about future ProfMessage Id needs 2020-04-06 21:17:42 +02:00
Michael Vetter
0becb68341 Add comment what id is about 2020-04-06 21:15:51 +02:00
Michael Vetter
3524a53c7c Add type field to ProfMessage
The mucuser boolean is not now needed anymore.
2020-04-06 19:15:02 +02:00
Michael Vetter
067bc690f2 Adapt win_print_history() to work with muc too 2020-04-06 15:33:01 +02:00
Michael Vetter
a0a4fd0426 db: log all incoming and outgoing messages 2020-04-06 10:50:20 +02:00
Michael Vetter
a4b53550ca Rename PROF_MSG_ENC_PLAIN to PROF_MSG_ENC_NONE 2020-04-06 10:50:20 +02:00
Michael Vetter
d1d0ad8d1a Add timestamp for incoming messages if none is set
Timestamps are only set if a message is delayed.
If none is set let's set it upon recaival so we don't have to set it
when it gets displayed.

This means we will also have it for logs etc in the ProfMessage.
2020-04-06 10:50:20 +02:00
Dmitry Podgorny
ded48a7e40 Fix memory leak in stanza_attach_correction()
xmpp_stanza_add_child() takes own reference to the child stanza.
Therefore we have to release our reference or the child is lost
and not freed otherwise.
2020-04-05 15:58:28 +03:00
Dmitry Podgorny
6c649a9de8 Fix memory leak of presence object
The memory leak happens when a presence is received for a MUC room. The
JID is not present in the roster, so updating its status is ignored. We
have to free resource in this case, because it has no owner and is lost
otherwise.

==25736== 47 (32 direct, 15 indirect) bytes in 1 blocks are definitely lost in loss record 1,625 of 3,399
==25736==    at 0x4A330FF: malloc (vg_replace_malloc.c:309)
==25736==    by 0x13A962: resource_new (resource.c:47)
==25736==    by 0x145501: _available_handler (presence.c:665)
==25736==    by 0x145501: _presence_handler (presence.c:399)
==25736==    by 0x145501: _presence_handler (presence.c:358)
==25736==    by 0x80D5F34: handler_fire_stanza (in /usr/lib64/libstrophe.so.0.0.0)
==25736==    by 0x80D2B49: _handle_stream_stanza (in /usr/lib64/libstrophe.so.0.0.0)
==25736==    by 0x80E15CE: _end_element (in /usr/lib64/libstrophe.so.0.0.0)
==25736==    by 0x843EE9B: doContent (in /usr/lib64/libexpat.so.1.6.10)
==25736==    by 0x843F94B: contentProcessor (in /usr/lib64/libexpat.so.1.6.10)
==25736==    by 0x8441E77: XML_ParseBuffer (in /usr/lib64/libexpat.so.1.6.10)
==25736==    by 0x80D586B: xmpp_run_once (in /usr/lib64/libstrophe.so.0.0.0)
==25736==    by 0x13E07E: connection_check_events (connection.c:119)
==25736==    by 0x13869C: prof_run (profanity.c:129)

Fixes #1279.
2020-02-23 08:51:36 +02:00
Michael Vetter
52e7e596aa xep-0084/avatar: add option to open avatar directly
Change:
`/avatar me@somewhere.org` -> `/avatar get me@somewhere.org`

New:
`/avatar cmd feh`
`/avatar open me@somewhere.org`

Implement https://github.com/profanity-im/profanity/issues/1281
2020-03-10 07:12:13 +01:00
Michael Vetter
56836fb72d Use correct MUC message timestamp
win_println_incoming_muc_msg() always used the current time. Now let's
use whatever is sent int he message struct (from the delay stanza or
the current time that we set now once the message is received).

No playing with the time upon display anymore.
2020-03-09 12:22:36 +01:00
Michael Vetter
8112b8c84b Use proper OS names for OpenBSD and NetBSD 2020-03-09 11:24:14 +01:00
Dmitry Podgorny
d18ec23d0a Fix few memory leaks 2020-02-27 01:35:36 +02:00
Michael Vetter
779c2efc17 Set muc history correctly in _handle_groupchat()
Fix init. mistake introduced in e9c5c1979d
2020-02-25 16:34:43 +01:00
Michael Vetter
063b5243f1 Free jid in muc_members_add()
Fix memleak.
2020-02-25 16:31:41 +01:00
Michael Vetter
62730367d6 Fix memleak in stanza_get_oldest_delay
We need to unref the temp datetimes again.
2020-02-25 15:54:44 +01:00
Michael Vetter
e9c5c1979d Fix memleak in _handle_groupchat()
We need to unref the timestamp before setting a new one.
2020-02-25 15:26:33 +01:00
Michael Vetter
8ee2cdadc8 Parse mentions and triggers in muc history if display is 'regular'
Fix https://github.com/profanity-im/profanity/issues/1261
2020-02-20 10:28:24 +01:00
Michael Vetter
e27c414f1f xep-0308: enable for carbon copied messages
If we are connected with another client and send a message, then correct
it. We now display it correctly in Profanity.

Id wasn't saved for carbon copied messages too so far.
2020-02-14 10:17:07 +01:00
Michael Vetter
4ec005e4c3 xep-0308: Implement LMC for outgoing MUC messages
Including OMEMO encrypted ones.
Also rename `win_println_me_message()` to `win_print_outgoing_muc_msg()
as I think it's a more descriptive name.
2020-02-14 10:17:07 +01:00
Michael Vetter
2a7a389cb5 Rename MUC PM handler
Rename from _private_chat_handler() to _handle_muc_private_message() to
be more consistent with other handler names.
2020-02-14 10:17:07 +01:00
Michael Vetter
66d3f572f9 xep-0308: Dont allow to correct MUC PMs
People could change messages of other people if the nick isn't
registered.
2020-02-14 10:17:00 +01:00
Michael Vetter
ed1d49bf0c xep-0308: correct incoming MUC PMs 2020-02-12 13:07:52 +01:00
Michael Vetter
7cd1be36f2 xep-0308: Display corrected incoming MUC messages correctly 2020-02-12 12:56:34 +01:00
Michael Vetter
11b6e1bfa0 xep-0308: enable corrections for outgoing encrypted messages 2020-02-12 08:54:12 +01:00
Michael Vetter
1118110071 xep-0308: Implement /correct to correct the last send message
So far the correction is sent. But the UI in Profanity itself is not
updated.

Also autocompletion for `/correct` with the last sent message is
missing.
2020-02-10 16:17:01 +01:00
Michael Vetter
dd8086772d xep-0308: create setting to toggle lmc
and print settings if only `/correction` is run.
2020-02-10 14:52:42 +01:00
Michael Vetter
f16d56a15e xep-0308: Initial support for incoming LMC 2020-02-10 13:19:54 +01:00
Michael Vetter
ce48525e99 avatar: use unique id for stanza id
"retrieve1" should have been only for testing.
2020-02-07 21:12:59 +01:00
Paul Fariello
a52e3ea1d8 Add context to autocomplete_with_func and use it for omemo trust command
Fix #1068
2020-01-31 10:07:08 +01:00
Michael Vetter
8fba8a8958 fix: Initialize variable in stanza_get_oldest_delay() 2020-01-30 12:35:49 +01:00
Michael Vetter
f80b2889ec Fix error in stanza_get_oldest_delay()
Introduced in bf2e09feee.
2020-01-30 11:54:03 +01:00
Michael Vetter
8a9488245b muc: save oldest timestamp
So far we saved the timestamp which also had the `from`.
But we need this only to find out whether it's MUC history.

For displaying we should use the oldest delay timestamp.

Also in
61f66966dd (diff-4926fd4577a336bd3eb240f8104a5c5bL837)
a error was introduced.

Before we saved the timestamp in all cases. And only if timestamp AND
from was given we went into MUC history case.
Normal timestamp saving was not done anymore only if it also had a from
attribute.

Regards https://github.com/profanity-im/profanity/issues/1254
2020-01-30 11:46:19 +01:00
Michael Vetter
bf2e09feee stanza: Refactor stanza_get_delay_from()
Have two helper functions one for XEP-0203 and one for XEP-0091.
2020-01-30 11:13:19 +01:00
Michael Vetter
388bae084b Revert "Save first delay tag as timestamp"
This reverts commit ef00b10c90.

According to reply by user in
https://github.com/profanity-im/profanity/issues/1254#issuecomment-578389784
it didn't help.
2020-01-28 11:42:24 +01:00
Michael Vetter
ef00b10c90 Save first delay tag as timestamp
So far we got the first delay with a from that comes from the server.
This way we know it's MUC history.

Now we take the first time stamp we actually find. Which is likely the
one being added first. And should contain the correct time to display.

It would be nicer to actually compare the dates though.

Regards https://github.com/profanity-im/profanity/issues/1254
2020-01-24 21:30:35 +01:00
Michael Vetter
3c0647ec70 Fix typo in comment 2020-01-23 23:57:18 +01:00
Michael Vetter
8c34f2ce01 xep-0092: add config option to set whether OS is revealed
Default is on. `revail.os=false` in the `connection` section of the
config can disable it.
A command to configure this will follow.
2020-01-23 23:35:46 +01:00
Michael Vetter
cb1dbb2732 xep-0092: send OS too
So far we only sent client name and version. Let's also send the OS
name.
2020-01-23 23:18:55 +01:00
Michael Vetter
2d19ad0db4 Add option to notify about version request
Cannot be configured for now.
Can be set via `adv.notify.discoversion` in the `notification` section.

Will notify about version requests via XEP-0092 and XEP-0232.

Client version can still be seen via caps (capabilities).
See `stanza_attach_caps()`.
2020-01-23 22:54:47 +01:00
Michael Vetter
3066fd77fc Save MUC room name in ProfMucWin
We will need this if we want to display the Name instead of the JID.
2020-01-23 11:35:33 +01:00
Michael Vetter
d4c27f2f78 xep-0084: use hash table for avatar lookup 2020-01-22 11:28:01 +01:00
Paul Fariello
c66cd17bbb Fix maybe uninitialized and don't guard g_free 2020-01-20 14:34:09 +01:00
Paul Fariello
0dfed1f4c7 Ignore invalid base64 in OMEMO stanzas
Fixes #1239
2020-01-20 14:34:09 +01:00
Paul Fariello
84506cbaeb Use OMEMO for offline MUC members (#1242) 2020-01-20 14:28:13 +01:00
Michael Vetter
33fca40b58
Merge pull request #1248 from svensp/master
OMEMO message keys allow prekey="1" alongside prekey="true"
2020-01-05 18:56:35 +01:00
Michael Vetter
be13e98fe7 Update my Copyright to 2020 2020-01-03 19:52:31 +01:00
Sven Speckmaier
5ccd04c91b omemo: Check for 1 alongside true in an omemo encrypted message stanza
prekey is defined as `<xs:attribute name="prekey" type="xs:boolean"/>`
which allows both `true` and `1` as truthy values.
Not checking for `1` breaks omemo encryption when interacting with
clients which set prekey="1", example: psi+ 1.4.983
Regards https://github.com/profanity-im/profanity/issues/1247
2020-01-03 10:39:40 +01:00
Michael Vetter
5d7f2d1516 Add comments to avatar.c
And use better function names.
2019-12-23 20:56:38 +01:00
Michael Vetter
5170a2d542 Add string.h to avatars.c
Regards https://github.com/profanity-im/profanity/issues/1241
2019-12-19 20:04:19 +01:00
Michael Vetter
6c2fd1a8ca Include stdlib.h in avatar.c
We use malloc() and free().

Fix https://github.com/profanity-im/profanity/issues/1241
2019-12-19 18:21:48 +01:00
Michael Vetter
9ac72980d1 xep-0084: add test stub file 2019-12-18 15:44:59 +01:00
Michael Vetter
53b92561cb Add header file guard to avatar.h 2019-12-18 15:33:16 +01:00
Michael Vetter
6978c39538 xep-0084: make internal functions static 2019-12-18 15:31:34 +01:00
Michael Vetter
da3ee9539d xep-0084: move id to avatar_metadata 2019-12-18 15:29:08 +01:00
Michael Vetter
fe41459d86 xep-0084: Add correct file extension 2019-12-18 15:20:07 +01:00
Michael Vetter
0ea1d3f85d xep-0084: Normalize at out of image filename 2019-12-18 14:36:18 +01:00
Michael Vetter
2b6b165ed2 xep-0084: Improve help 2019-12-18 14:35:47 +01:00
Michael Vetter
795ae00acf xep-0084:
So far we removed the avatar feature only after a succesful retrive in
avatar_request_item_by_id() before we are going to retrieve the actual
image.

We should remove it at every `/avatar barejid` call too so in case one
retrieval was unsucessful that we can call it again.

So far it seems like there is no other way to trigger getting the nodes
except announcing that we support the avatar feature.
2019-12-18 13:52:48 +01:00
Michael Vetter
64a86a1785 Fix header 2019-12-18 13:42:21 +01:00
Michael Vetter
3f58aba2bd xep-0084: save avatars in own directory 2019-12-18 13:29:28 +01:00
Michael Vetter
f692d6d0e0 xep-0084: Make it work multiple times 2019-12-18 13:14:17 +01:00
Michael Vetter
c2aa585615 xep-0084: Download avatars
Proof of concept.
Needs error checking, a nice interface, general cleanup..
2019-12-18 12:50:09 +01:00
Michael Vetter
e3538cf739 xep-0084: Look for specific user and print ID
Add a `/avatar` command.
2019-12-18 11:24:50 +01:00
Michael Vetter
771dfab123 Start implementing XEP-0084
So far we just subscribe and get the IDs.
2019-12-18 10:17:10 +01:00
Michael Vetter
548b64f6c5 Fix stanza_get_child_by_name_and_from() strcmp
Fix https://github.com/profanity-im/profanity/issues/1227
2019-11-14 19:22:06 +01:00
Michael Vetter
46fd7150e5 Add vim modeline 2019-11-13 12:11:05 +01:00
Michael Vetter
61f66966dd Check for correct delay tag for muc timestamps
https://github.com/profanity-im/profanity/issues/1190 had another issue:
Sometimes servers send multiple </delay> and we just checked the first
one we got and only used it if the 'from' attribute was fitting.
However it could be that we actually wanted the second </delay> element
and there the 'from' would have been right.

So we need to loop through them until we get the one with the fitting
'from'.

Fix https://github.com/profanity-im/profanity/issues/1190
2019-11-13 09:41:19 +01:00
Michael Vetter
196e029b47 Fix stanza_get_child_by_name_and_ns() if no name
Fix bug introduced in 68af0aad65.
2019-11-12 16:18:28 +01:00
Michael Vetter
68af0aad65 _handle_groupchat(): get correct origin-id stanza
The problem is that in _handle_groupchat() we look for
STANZA_NS_STABLE_ID which will result in origin-id or stanza-id.
It seems like prosody servers send origin-id first, so this worked in
all my tests. But actually we cannot be sure of the order.
So far we stopped after the first element was found.

I only found xmpp_stanza_get_child_by_ns() and
xmpp_stanza_get_child_by_name() in libstrophe. But we need a combination
of both.

So I created stanza_get_child_by_name_and_ns() for Profanity. I need to
remember to upstream this to libstrophe later (if they really don't have
such a function).

Fix https://github.com/profanity-im/profanity/issues/1223
2019-11-08 15:05:49 +01:00
Michael Vetter
f71de61b9d Don't override ProfMessage Id with origin-id
Profanity sends the same value for both. Other clients might not.
Safe both since we could need them later.

Once we implement Last Message Correction we will need the regular id.
If we override it with origin-id and another client chooses to not use
the same value for id and origin-id then we can't interpret the id sent
with the LMC request correctly.
2019-10-31 13:45:44 +01:00
aszlig
b1e960cfae
omemo: Check stanza names when iterating nodes
Some clients (eg. PSI) are sending the stanzas delimited by whitespace
text nodes, which will fail while looping through the <prekeys/>
children and also print weird errors when iterating through the <list/>
of devices.

When debugging this, I was looking at the XML of Gajim and PSI and first
was somehow confused why Profanity printed "OMEMO: received device
without ID" while the XML looked identical (minus the actual IDs and the
JIDs of course).

However, Gajim was sending the XML without whitespace nodes in between
and PSI did not, so for example the following (with the relevant
whitespace nodes marked with X):

  <message type="headline" to="..." from="...">
    <event xmlns="http://jabber.org/protocol/pubsub#event">
      <items type="headline" node="eu.siacs.conversations.axolotl.devicelist">
        <item id="...">
          <list xmlns="eu.siacs.conversations.axolotl">
          X <device id="..."/>
          X <device id="..."/> X
          </list>
        </item>
      </items>
    </event>
    <delay xmlns="urn:xmpp:delay" stamp="..." from="..."/>
  </message>

... would result in three times the "OMEMO: received device without ID"
error, because we actually have three XML text nodes here that obviously
don't have an "id" attribute.

Now since the <list/> children above aren't really a problem and only
annoying, text nodes in the <prekeys/> stanza actually cause
omemo_start_device_session_handle_bundle to return failure.

I've fixed this by explicitly matching the stanza names we are
interested in, skipping everything else.

Signed-off-by: aszlig <aszlig@nix.build>
Reported-by: @devhell
2019-10-29 23:10:07 +01:00
Michael Vetter
7dd747b58d Set mucuser in carbon case
Also we initialize mucuser properly.

Now in case of a carbon of a MUC PM we sv_ev_incoming_carbon() which
calls _sv_ev_incoming_plain() and then we log it via chat_log_msg_in()
in there.
But we also get the sv_ev_incoming_private_message() and call
chat_log_msg_in() in there too. So the incoming message get's logged
twice.
2019-10-29 10:41:07 +01:00
Michael Vetter
22bf281399 Make prof_identifier const 2019-10-22 12:47:32 +02:00
Michael Vetter
6b75848f96 Display ownership of connection_get_profanity_identifier 2019-10-22 12:04:16 +02:00
Michael Vetter
ba18752405 Use UUID in origin-id and id
Let's use UUID to have a more random string then just 10 alphanumeric
values.
2019-10-22 11:10:37 +02:00
Michael Vetter
ef19b45e64 Remove old comment
It's not up to date.
Some time ago we changed from individual handlers to general ones.
2019-10-21 10:28:29 +02:00
Michael Vetter
963ab841b4 Set prof_ident to NULL after free
This caused the bug mentioned in the PR comment:

```
It seems with the changes done here we get a crash in: src/xmpp/message.c message_handlers_init() when looking up handlers: ProfMessageHandler *handler = g_hash_table_lookup(pubsub_event_handlers, curr->data);.

Steps to reproduce:

    open Profanity and connect
    /autoping set 10
    /autoping timeout 10
    stop WiFi/connection
    wait for Lost connection
    restart wifi
    /connect
```
2019-10-21 09:50:13 +02:00
Michael Vetter
8a5932b251 Rename _calculate_identifier to _compute_identifier 2019-10-20 00:01:19 +02:00
Michael Vetter
db4b55eee0 Rename random_bytes to profanity_instance_id 2019-10-19 23:27:19 +02:00
Michael Vetter
2a4d1b8410 Free hmac and msgid 2019-10-19 08:18:37 +02:00
Michael Vetter
f190d2c5f2 Free prof_identifier in case of reconnect
Bedore we assign it new.
2019-10-19 07:40:59 +02:00
Michael Vetter
c3912df05b Move ProfMessage and message_is_sent_by_us to xmpp
Not meant for internal usage only.
2019-10-19 06:36:47 +02:00
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
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
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
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
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
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
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
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
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
Paul Fariello
b3e59e1fb6 Fix memleak in /cmd exec 2019-07-30 13:35:08 +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
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
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
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
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
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
b110da9a92 Fix various OMEMO memleaks 2019-07-10 17:32:23 +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