Skip to content

fix(dtls): remove duplicate DEL_PEER in handle_alert()#271

Closed
re2zero wants to merge 1 commit into
eclipse-tinydtls:mainfrom
re2zero:fix/issue-269-double-del-peer
Closed

fix(dtls): remove duplicate DEL_PEER in handle_alert()#271
re2zero wants to merge 1 commit into
eclipse-tinydtls:mainfrom
re2zero:fix/issue-269-double-del-peer

Conversation

@re2zero
Copy link
Copy Markdown

@re2zero re2zero commented May 28, 2026

Summary

  • Remove duplicate DEL_PEER() call in handle_alert() to fix uthash corruption

Problem

handle_alert() calls DEL_PEER() to remove the peer from the hash table, then calls dtls_destroy_peer() which calls DEL_PEER() again on the same peer. Since HASH_DELETE_HH in uthash does not check if the entry is in the table, this double removal corrupts the hash table bucket chains and num_items counter, potentially leading to crashes or use-after-free.

Fix

Remove the DEL_PEER() call from handle_alert() since dtls_destroy_peer() already handles the complete peer cleanup including removal from the hash table.

Changes

File Change
dtls.c Remove duplicate DEL_PEER() in handle_alert(), update comment

Fixes #269

handle_alert() calls DEL_PEER() to remove the peer from the hash
table, then calls dtls_destroy_peer() which calls DEL_PEER() again.
This double removal corrupts the uthash hash table and can lead
to crashes or undefined behavior.

Remove the DEL_PEER() call from handle_alert() since
dtls_destroy_peer() already handles peer cleanup including
removal from the hash table.

Fixes eclipse-tinydtls#269
@re2zero
Copy link
Copy Markdown
Author

re2zero commented May 28, 2026

Closing this PR as I am unable to complete the Eclipse Contributor Agreement (ECA) requirement. The fix itself is straightforward: remove the duplicate DEL_PEER() call in handle_alert() to prevent uthash corruption. Feel free to take the patch.

@re2zero re2zero closed this May 28, 2026
@boaks
Copy link
Copy Markdown
Contributor

boaks commented May 29, 2026

PR #270 is already addressing that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double DEL_PEER in handle_alert()

2 participants