[Spice-devel] [vdagent-win PATCH] vdservice: add quotes to service path
Hans de Goede
hdegoede at redhat.com
Tue Apr 9 06:31:19 PDT 2013
Hi,
On 04/09/2013 03:25 PM, agilboa at redhat.com wrote:
> On 04/09/2013 04:12 PM, Hans de Goede wrote:
>> 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 ?
>>
> The old size given to GetModuleFileName was bogus.
> Note in XP:
> "The string is truncated to nSize characters and is not null-terminated...
> If the buffer is too small to hold the module name, the function returns nSize".
> That's why we now check (len == 0 || len == _MAX_PATH)
Ok, ack then.
Regards,
Hans
More information about the Spice-devel
mailing list