[
https://issues.apache.org/jira/browse/DAEMON-390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603598#comment-16603598
]
Sebb commented on DAEMON-390:
-----------------------------
The size of the wsAdd buffer is al + rc + 1
So I would expect the method call at line 73 to use the buffer length
{code}
al + rc +1 - al
{code}
i.e.
{code}
rc + 1
{code}
Or am I missing something here?
Note: the return from GetEnvironmentVariable is the length (excluding
terminating null) if it succeeds, and length +1 (for terminating null) if the
buffer is too short. [1]
Since the call that sets up rc uses a buffer length of 0, it will fail and thus
return the length +1, i.e. the code does not need to add + 1 at line 68.
However having done so, logically line 73 should include the + 1 in the buffer
length.
[1]
https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getenvironmentvariable
> PATH environment variable is not properly set if using LibraryPath option
> -------------------------------------------------------------------------
>
> Key: DAEMON-390
> URL: https://issues.apache.org/jira/browse/DAEMON-390
> Project: Commons Daemon
> Issue Type: Bug
> Components: Procrun
> Affects Versions: 1.1.0
> Reporter: Robert Krzeminski
> Priority: Major
> Labels: easyfix, patch, windows
> Attachments: apxAddToPathW-1-1-1-0.patch
>
>
> The PATH environment variable is not properly set if command line option
> LibraryPath is used. It shall extend the existing PATH variable with
> additional directories defined as library path. In the current implementation
> the wrong buffer size for the retrieved environment variable is passed during
> the call to GetEnvironmentVariableW from utility function apxAddToPathW
> (utils.c). Attached a patch that contains the fix for this issue.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)