From 094d33d4073368ab1a85fcf63e3b75addb01fd6a Mon Sep 17 00:00:00 2001 From: Tomas Illuminati Balbin Date: Mon, 20 Apr 2026 09:17:13 -0300 Subject: [PATCH] Update src/twisted/names/dns.py Co-authored-by: Adi Roiban CVE: CVE-2026-42304 Upstream-Status: Backport [https://github.com/twisted/twisted/commit/86e1b5490de5baa8ca284d1e6f4f0ade3e8ad7e0] (cherry picked from commit 86e1b5490de5baa8ca284d1e6f4f0ade3e8ad7e0) Signed-off-by: Hetvi Thakar --- src/twisted/names/dns.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/twisted/names/dns.py b/src/twisted/names/dns.py index 7142d9e75..93e4080bf 100644 --- a/src/twisted/names/dns.py +++ b/src/twisted/names/dns.py @@ -2784,8 +2784,7 @@ class Message(tputil.FancyEqMixin): # performed across every name in this message. It is installed on # the context variable so nested record decoders pick it up without # needing to thread it through each signature. - token = _decodeContextVar.set(_DecodeContext()) - try: + with _decodeContextVar.set(_DecodeContext()): self.queries = [] for i in range(nqueries): q = Query()