Re: [vdagent-win PATCH] vdservice: add quotes to service path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 04/09/2013 03:02 PM, Arnon Gilboa wrote:
for the case path contains a space, see CreateService() doc:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682450.aspx

rhbz #918635
---
  vdservice/vdservice.cpp |    8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 9134c4b..89e0dbb 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -170,12 +170,16 @@ bool VDService::install()
          printf("OpenSCManager failed\n");
          return false;
      }
-    TCHAR path[_MAX_PATH + 1];
-    if (!GetModuleFileName(0, path, sizeof(path) / sizeof(path[0]))) {
+    TCHAR path[_MAX_PATH + 2];

Shouldn't that be _MAX_PATH + 3, 2 quotes + 0, or does GetModuleFileName
already take the terminating 0 into account and was the old + 1 bogus ?



+    DWORD len = GetModuleFileName(0, path + 1, _MAX_PATH);
+    if (len == 0 || len == _MAX_PATH) {
          printf("GetModuleFileName failed\n");
          CloseServiceHandle(service_control_manager);
          return false;
      }
+    // add quotes for the case path contains a space (see CreateService doc)
+    path[0] = path[len + 1] = TEXT('\"');
+    path[len + 2] = 0;
      SC_HANDLE service = CreateService(service_control_manager, VD_SERVICE_NAME,
                                        VD_SERVICE_DISPLAY_NAME, SERVICE_ALL_ACCESS,
                                        SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,


Regards,

Hans
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]