[OpenSIPS-Devel] [OpenSIPS/opensips] fefd8e: aaa_diameter: always release reply cJSON regardles...

Ravitez Dondeti noreply at github.com
Thu Jun 18 15:53:31 UTC 2026


  Branch: refs/heads/3.6
  Home:   https://github.com/OpenSIPS/opensips
  Commit: fefd8e403978fa61be19860ba7eba8dbce9b4a6f
      https://github.com/OpenSIPS/opensips/commit/fefd8e403978fa61be19860ba7eba8dbce9b4a6f
  Author: dondetir <ravitez.dondeti at gmail.com>
  Date:   2026-06-18 (Thu, 18 Jun 2026)

  Changed paths:
    M modules/aaa_diameter/aaa_diameter.c

  Log Message:
  -----------
  aaa_diameter: always release reply cJSON regardless of output PV

_dm_release_message_response() is the only function that frees the
SHM-backed cJSON reply tree (cond->rpl.json).  In dm_send_request(),
the release call was gated inside "if (rpl_avps_pv)", so every call
without an output PV leaked the entire SHM cJSON tree.

The same issue existed in dm_send_request_async_reply(): the release
was guarded by "if (rpl_avps)", which was NULL both when no output PV
was configured and on the read() failure path — even though the reply
callback had already populated cond->rpl.json.

_dm_release_message_response() safely handles a NULL rpl_avps argument
(cJSON_PurgeString is a no-op on NULL), so removing both guards is safe.

Found during a systematic audit of dm_send_request() paths following
commit 1e8001fa0.

(cherry picked from commit f40e0dab7ef48010526ef0f7dd2c77d0215b1ceb)


  Commit: 38ca45ab92f6a43a07d54001848d8995f7332cfd
      https://github.com/OpenSIPS/opensips/commit/38ca45ab92f6a43a07d54001848d8995f7332cfd
  Author: dondetir <ravitez.dondeti at gmail.com>
  Date:   2026-06-18 (Thu, 18 Jun 2026)

  Changed paths:
    M modules/aaa_diameter/dm_impl.c

  Log Message:
  -----------
  aaa_diameter: fix double-free of cJSON item in dm_avps2json()

After cJSON_AddItemToArray(avps, item) transfers ownership of item to
avps, item is not cleared.  Any subsequent FD_CHECK_GT failure in the
same or next loop iteration jumps to the out: label, which calls
cJSON_Delete(item) — freeing memory already owned by avps.

This double-free corrupts the SHM heap, affecting all worker processes.
The affected paths include:
  - FD_CHECK_GT(fd_msg_browse()) at the skip: label (next-iteration
    advance)
  - FD_CHECK_GT(fd_msg_avp_hdr()) and FD_CHECK_GT(fd_dict_getval())
    at the start of the next iteration

Fix: clear item immediately after the ownership transfer so that any
later cJSON_Delete(item) at out: is a safe no-op.

Found during a systematic audit following commit 1e8001fa0.

(cherry picked from commit 7fef0814dac887ad1041af97ccf4ac1ff457550a)


Compare: https://github.com/OpenSIPS/opensips/compare/02dc674268db...38ca45ab92f6

To unsubscribe from these emails, change your notification settings at https://github.com/OpenSIPS/opensips/settings/notifications



More information about the Devel mailing list