Sophie

Sophie

distrib > Mageia > 9 > x86_64 > by-pkgid > 86afe67f96b9d780a87eb6b385d905f4 > files > 2

dcmtk-3.6.7-4.mga9.src.rpm

From cd73ffc250bf6472afdd17170eb688243701f860 Mon Sep 17 00:00:00 2001
From: Marco Eichelberg <dicom@offis.de>
Date: Thu, 9 Jun 2022 10:03:38 +0200
Subject: [PATCH 18/18] [CVE-2022-43272] Fixed memory leak in single process
 mode.

Fixed a memory leak in dcmqrscp's single process mode.

Thanks to <songxiangpu@mail.sdu.edu.cn> for the bug report and test data.

(cherry picked from commit c34f4e46e672ad21accf04da0dc085e43be6f5e1)
---
 dcmqrdb/libsrc/dcmqrsrv.cc | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/dcmqrdb/libsrc/dcmqrsrv.cc b/dcmqrdb/libsrc/dcmqrsrv.cc
index 157e6c022..f5f9df661 100644
--- a/dcmqrdb/libsrc/dcmqrsrv.cc
+++ b/dcmqrdb/libsrc/dcmqrsrv.cc
@@ -1,6 +1,6 @@
 /*
  *
- *  Copyright (C) 1993-2021, OFFIS e.V.
+ *  Copyright (C) 1993-2022, OFFIS e.V.
  *  All rights reserved.  See COPYRIGHT file for details.
  *
  *  This software and supporting documentation were developed by
@@ -1126,21 +1126,17 @@ OFCondition DcmQueryRetrieveSCP::waitForAssociation(T_ASC_Network * theNet)
 #endif
     }
 
-    // cleanup code
+    // clean-up association
     OFCondition oldcond = cond;    /* store condition flag for later use */
-    if (!options_.singleProcess_ && (cond != ASC_SHUTDOWNAPPLICATION))
+    cond = ASC_dropAssociation(assoc);
+    if (cond.bad())
     {
-        /* the child will handle the association, we can drop it */
-        cond = ASC_dropAssociation(assoc);
-        if (cond.bad())
-        {
-            DCMQRDB_ERROR("Cannot Drop Association: " << DimseCondition::dump(temp_str, cond));
-        }
-        cond = ASC_destroyAssociation(&assoc);
-        if (cond.bad())
-        {
-            DCMQRDB_ERROR("Cannot Destroy Association: " << DimseCondition::dump(temp_str, cond));
-        }
+        DCMQRDB_ERROR("Cannot Drop Association: " << DimseCondition::dump(temp_str, cond));
+    }
+    cond = ASC_destroyAssociation(&assoc);
+    if (cond.bad())
+    {
+        DCMQRDB_ERROR("Cannot Destroy Association: " << DimseCondition::dump(temp_str, cond));
     }
 
     if (oldcond == ASC_SHUTDOWNAPPLICATION) cond = oldcond; /* abort flag is reported to top-level wait loop */
-- 
2.39.2