Commit Graph

13 Commits

Author SHA1 Message Date
Frediano Ziglio
c8fd498b7f display_setting: Remove a warning
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>
2020-03-23 12:36:59 +00:00
Frediano Ziglio
7b368a134f Allow one more character reading strings from registry
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>
2018-07-05 14:12:33 +01:00
Frediano Ziglio
1a2e2d1411 Factor out an utility function to read strings from registry
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-05 14:12:33 +01:00
Frediano Ziglio
97ef38dc6d Use always TCHAR to read string from registry
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>
2018-07-05 14:12:33 +01:00
Frediano Ziglio
13fb63e328 Fix some minor buffer overflows reading registry informations
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>
2018-06-29 19:22:42 +01:00
Frediano Ziglio
011d60e628 Fix include syntax
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-01 15:45:17 +01:00
Victor Toso
8ae139f363 vdagent: remove whitespaces
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-12 09:41:41 +01:00
Sameeh Jubran
107b351795 Fixing buffer overflow when reloading wallpaper
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>
2016-08-01 14:23:28 +02:00
Marc-André Lureau
ad61eec961 Fix cast BOOL->PVOID warning
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)) {
2013-07-17 20:52:17 +02:00
Christophe Fergeau
a8b47ea653 mingw: remove unused variable 2012-03-01 12:58:29 +01:00
Christophe Fergeau
9d1586c1dd mingw: fix header case
linux systems need it in lower-case, Windows systems shouldn't
care.
2012-03-01 12:58:29 +01:00
Christophe Fergeau
df3fe9cb90 mingw: fix format string warnings
Most of them are caused by not using %lu to print a DWORD (which
is an unsigned long).
2012-02-23 19:03:25 +01:00
Yonit Halperin
5833dc9760 Controlling Windows display settings (e.g., wallpaper, UI effects and font smoothing)
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.
2010-08-24 10:36:05 +03:00