Avoids:
warning C4267: 'initializing': conversion from 'size_t' to 'DWORD', possible loss of data
Value won't never be that huge to cause overflow (we are reading a string
in a static buffer, we don't expect an encyclopedia).
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
The strings in the registry are usually NUL-terminated but this
is not a requirement.
Handle the case when the string, considering the terminator, fit
into the reading buffer. In this case accept the string. In the
case the string fit into the buffer but is not terminated
returns ERROR_MORE_DATA (the error that would be returned if the
string didn't fit in the buffer as there is no place to add the
terminator).
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This is a preparation patch in order to factor out code to read
a string from registry.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Strings in the registry can be not NUL-terminated.
Current code to make sure they are NUL-terminated can add an extra
NUL character at the end of the buffer.
Also RegQueryValueEx returns the number of bytes read, not the number
of characters so the value must be fixed to avoid overflows.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
The function "SystemParametersInfo" expects the size of the
buffer in characters. When wchar is used instead of char - two
bytes instead of one byte per character -, then "sizeof" returns wrong
number of characters (twice as much). A suitable solution would be to use
SPICE_N_ELEMENTS.
Based on patch by Sandy Stutsman <sstutsma@redhat.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
vdagent/display_setting.cpp:469:50: warning: cast to pointer from
integer of different size [-Wint-to-pointer-cast]
if (!SystemParametersInfo(action, 0, (PVOID)param, 0)) {
The configuration is received from Spice client.
The main usage of this option is for disabling display features in order to accelerate Spice performance over limited network connections.