Skip to contentSkip to conversation

dco_linux: properly close dco version file

PATCH In review Frank Lichtenheld 2 participants 2 messages May 12, 2023 – May 13, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dco_linux: properly close dco version file

Since we only call this once, it is not a bad
leak, but still.

Change-Id Id85766738c3ece4f2d1860f7d101e4446a894aed
---
 src/openvpn/dco_linux.c | 2 ++
 1 file changed, 2 insertions(+)
src/openvpn/dco_linux.c +2 -0
index 41540c0f..796e6f25 100644
@@ -1020,6 +1020,7 @@ dco_version_string(struct gc_arena *gc)
 
     if (!fgets(BSTR(&out), BCAP(&out), fp))
     {
+        fclose(fp);
         return "ERR";
     }
 
@@ -1031,6 +1032,7 @@ dco_version_string(struct gc_arena *gc)
         *nl = '\0';
     }
 
+    fclose(fp);
     return BSTR(&out);
 }
 
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw

"Obviously correct in hindsight"... (there is other weirdness in this function, like, "why use a struct buffer if all you want is a gc-allocated char[256]?", but that's for a different day to fix).

Have stared-at-code and test compiled on Linux.

Your patch has been applied to the master and release/2.6 branch.

commit cf496476b364f8613bacd48e10d6a1bbbf0aceda (master) commit 26ea58f94ce10e108aa7c607b0a7dcb3419449fc (release/2.6)

Author: Frank Lichtenheld
Date:   Fri May 12 17:50:23 2023 +0200
     dco_linux: properly close dco version file

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg26650.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering