Changeset 5d9257cf for protocols


Ignore:
Timestamp:
2023-04-07T20:43:51Z (13 months ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
cad74fb
Parents:
d36ef38
git-author:
dx <dx@…> (07-04-23 20:43:51)
git-committer:
GitHub <noreply@…> (07-04-23 20:43:51)
Message:

jabber: fix regression with gchecksum in jabber_cache_add (#186)

This crashed with "The checksum '%s' has been closed and cannot be
updated anymore." (which is also a user after free)

Issue introduced in 1bdc6696aefb617873b56001f81d649d6ca3aa8e which is
not in any released version.

There was this md5_digest_keep() function that freed a copy of the
checksum instead of the one you pass. The code that it was replaced with
ignored this distinction, and since jabber_cache_add() needs to reuse the
GChecksum this led to this issue.

No other place in the bitlbee code used this function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber_util.c

    rd36ef38 r5d9257cf  
    140140        struct jabber_data *jd = ic->proto_data;
    141141        struct jabber_cache_entry *entry = g_new0(struct jabber_cache_entry, 1);
    142         GChecksum *id_hash;
     142        GChecksum *id_hash, *copy;
    143143        gsize digest_len = MD5_HASH_SIZE;
    144144        guint8 id_sum[MD5_HASH_SIZE];
     
    149149        id_hash = jd->cached_id_prefix;
    150150        g_checksum_update(id_hash, (guint8 *) &next_id, sizeof(next_id));
    151         g_checksum_get_digest(id_hash, id_sum, &digest_len);
    152         g_checksum_free(id_hash);
     151
     152        copy = g_checksum_copy(id_hash);
     153        g_checksum_get_digest(copy, id_sum, &digest_len);
     154        g_checksum_free(copy);
    153155
    154156        asc_hash = base64_encode(id_sum, 12);
Note: See TracChangeset for help on using the changeset viewer.