Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/dxcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,15 @@ static int dxcore_query_adapter_driverstore(struct dxcore_lib* pLib, unsigned in
free(pValue);
return (-1);
}
wcstombs(*ppDriverStorePath, pOutput, outputSize);
/*
* wcstombs() expects the size of the destination buffer in bytes. The
* buffer allocated above is `outputSize + 1` bytes long, which includes
* room for the terminating NUL byte. Passing only `outputSize` could
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* room for the terminating NUL byte. Passing only `outputSize` could
* room for the terminating NULL byte. Passing only `outputSize` could

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolved as this has not been addressed.

* prevent the terminator from being written when the converted string
* length equals `outputSize`. Use the full buffer size here to ensure
* the resulting string is always NUL terminated.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* the resulting string is always NUL terminated.
* the resulting string is always NULL terminated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolved as this has not been addressed.

*/
wcstombs(*ppDriverStorePath, pOutput, outputSize + 1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a matter of interest, is this something that you've run into?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jbujak


free(pValue);

Expand Down