[Openvpn-devel,02/12] openvpnmsica: Fix TAPInterface.DisplayName field interpretation

Message ID 20200309131728.380-2-simon@rozman.si
State Accepted
Headers show
Series
  • [Openvpn-devel,01/12] openvpnmsica: Remove required Windows driver certification detection
Related show

Commit Message

Simon Rozman March 9, 2020, 1:17 p.m.
The DisplayName field type is Filename in the MSI database. This means
it must be authored as "8.3" filename, or "8.3|long filename".

This issue does not appear until interface names grow longer than 8
characters, or contain characters invalid in 8.3 filename notation.

Signed-off-by: Simon Rozman <simon@rozman.si>
---
 src/openvpnmsica/openvpnmsica.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Gert Doering March 9, 2020, 2:24 p.m. | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

I won't claim to understand what this all does, but the change matches
the documentation - if a "file name" is returned that has "8.3|long"
format, it will use the "long" part of it, otherwise the string as it is.

Your patch has been applied to the master branch.

commit 36493bf6383767fe4e20f1dfda6be2a7ee0dc1f2
Author: Simon Rozman
Date:   Mon Mar 9 14:17:18 2020 +0100

     openvpnmsica: Fix TAPInterface.DisplayName field interpretation

     Signed-off-by: Simon Rozman <simon@rozman.si>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20200309131728.380-2-simon@rozman.si>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19520.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c
index 4236330a..e1f0b77d 100644
--- a/src/openvpnmsica/openvpnmsica.c
+++ b/src/openvpnmsica/openvpnmsica.c
@@ -2,7 +2,7 @@ 
  *  openvpnmsica -- Custom Action DLL to provide OpenVPN-specific support to MSI packages
  *                  https://community.openvpn.net/openvpn/wiki/OpenVPNMSICA
  *
- *  Copyright (C) 2018 Simon Rozman <simon@rozman.si>
+ *  Copyright (C) 2018-2020 Simon Rozman <simon@rozman.si>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2
@@ -752,6 +752,9 @@  EvaluateTAPInterfaces(_In_ MSIHANDLE hInstall)
         {
             goto cleanup_hRecord;
         }
+        /* `DisplayName` field type is [Filename](https://docs.microsoft.com/en-us/windows/win32/msi/filename), which is either "8.3|long name" or "8.3". */
+        LPTSTR szDisplayNameEx = _tcschr(szDisplayName, TEXT('|'));
+        szDisplayNameEx = szDisplayNameEx != NULL ? szDisplayNameEx + 1 : szDisplayName;
 
         if (iAction > INSTALLSTATE_BROKEN)
         {
@@ -796,7 +799,7 @@  EvaluateTAPInterfaces(_In_ MSIHANDLE hInstall)
                         msica_op_tap_interface_create,
                         MSICA_INTERFACE_TICK_SIZE,
                         NULL,
-                        szDisplayName));
+                        szDisplayNameEx));
             }
             else
             {
@@ -807,7 +810,7 @@  EvaluateTAPInterfaces(_In_ MSIHANDLE hInstall)
                         msica_op_tap_interface_delete_by_name,
                         MSICA_INTERFACE_TICK_SIZE,
                         NULL,
-                        szDisplayName));
+                        szDisplayNameEx));
             }
 
             /* The amount of tick space to add for each interface to progress indicator. */