mingw-spice-vdagent package is retired on branch c10s for CS-2551

This commit is contained in:
Johnny Hughes 2024-10-02 16:05:44 +00:00
parent 2fe2e82978
commit 66ecdc6b25
22 changed files with 4 additions and 1351 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
SOURCES/vdagent-win-0.9.0.tar.xz
/vdagent-win-0.9.0.tar.xz

View File

@ -1,56 +0,0 @@
From aaeecf129424752b13373a9242bcede58337e047 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Tue, 22 Aug 2017 12:51:45 +0100
Subject: [PATCH 01/43] Make BitmapCoder::from_bitmap return a BMP file format
The network expect the format of the data to match a file
format so prepending DIB data with BITMAPFILEHEADER change
the format from DIB to BMP file.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
---
vdagent/image.cpp | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/vdagent/image.cpp b/vdagent/image.cpp
index 82cfb0e..15bd4fa 100644
--- a/vdagent/image.cpp
+++ b/vdagent/image.cpp
@@ -150,6 +150,8 @@ void BitmapCoder::get_dib_data(uint8_t *dib, const uint8_t *data, size_t size)
uint8_t *BitmapCoder::from_bitmap(const BITMAPINFO& info, const void *bits, long &size)
{
+ BITMAPFILEHEADER file_hdr;
+
const BITMAPINFOHEADER& head(info.bmiHeader);
const DWORD max_palette_colors = head.biBitCount <= 8 ? 1 << head.biBitCount : 0;
@@ -157,14 +159,21 @@ uint8_t *BitmapCoder::from_bitmap(const BITMAPINFO& info, const void *bits, long
const size_t stride = compute_dib_stride(head.biWidth, head.biBitCount);
const size_t image_size = stride * head.biHeight;
- size = sizeof(head) + palette_size + image_size;
+ size = sizeof(file_hdr) + sizeof(head) + palette_size + image_size;
+
+ file_hdr.bfType = 'B' + 'M'*256u;
+ file_hdr.bfSize = size;
+ file_hdr.bfReserved1 = 0;
+ file_hdr.bfReserved2 = 0;
+ file_hdr.bfOffBits = sizeof(file_hdr) + sizeof(head) + palette_size;
uint8_t *data = (uint8_t *) malloc(size);
if (!data) {
return NULL;
}
- memcpy(data, &info, sizeof(head) + palette_size);
- memcpy(data + sizeof(head) + palette_size, bits, image_size);
+ memcpy(data, &file_hdr, sizeof(file_hdr));
+ memcpy(data + sizeof(file_hdr), &info, sizeof(head) + palette_size);
+ memcpy(data + sizeof(file_hdr) + sizeof(head) + palette_size, bits, image_size);
return data;
}
--
2.17.1

View File

@ -1,62 +0,0 @@
From 9c85f8d3caf826099d8a1db562e23e5cf4e8b243 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Tue, 22 Aug 2017 12:57:16 +0100
Subject: [PATCH 02/43] imagetest: Save PNG file using a helper function
This allows to reuse the code to save a DIB to a file.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
---
vdagent/imagetest.cpp | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/vdagent/imagetest.cpp b/vdagent/imagetest.cpp
index 319b188..3a553a9 100644
--- a/vdagent/imagetest.cpp
+++ b/vdagent/imagetest.cpp
@@ -23,6 +23,23 @@
#include "image.h"
#include "imagepng.h"
+static void
+save_dib_to_file(ImageCoder& coder, const uint8_t *raw_dib, const char *filename)
+{
+ const BITMAPINFO& info(*(BITMAPINFO*) raw_dib);
+ const uint8_t *raw_bits = &raw_dib[sizeof(BITMAPINFOHEADER) + 4 * info.bmiHeader.biClrUsed];
+
+ long size = 0;
+ uint8_t *raw_file = coder.from_bitmap(info, raw_bits, size);
+ assert(raw_file && size > 0);
+
+ FILE *f = fopen(filename, "wb");
+ assert(f);
+ assert(fwrite(raw_file, 1, size, f) == (unsigned long) size);
+ fclose(f);
+ free(raw_file);
+}
+
int main(int argc, char **argv)
{
ImageCoder *coder = create_png_coder();
@@ -66,16 +83,7 @@ int main(int argc, char **argv)
fclose(f);
// convert back to PNG
- long png_size = 0;
- uint8_t *png = coder->from_bitmap(*((BITMAPINFO*)&out[0]), &out[sizeof(BITMAPINFOHEADER) + 4 * info.biClrUsed], png_size);
- assert(png && png_size > 0);
-
- f = fopen(argc > 3 ? argv[3] : "out.png", "wb");
- assert(f);
- assert(fwrite(png, 1, png_size, f) == (unsigned long) png_size);
- fclose(f);
- free(png);
- png = NULL;
+ save_dib_to_file(*coder, &out[0], argc > 3 ? argv[3] : "out.png");
return 0;
}
--
2.17.1

View File

@ -1,89 +0,0 @@
From 16aee83802ee436cc5216bd55cb8f7760c30f50a Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Tue, 22 Aug 2017 12:58:25 +0100
Subject: [PATCH 03/43] imagetest: Save BMP file using BitmapCoder
This allows to test BitmapCoder::from_bitmap.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
---
vdagent/image.cpp | 2 --
vdagent/image.h | 2 ++
vdagent/imagetest.cpp | 20 ++++++--------------
3 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/vdagent/image.cpp b/vdagent/image.cpp
index 15bd4fa..1b21b53 100644
--- a/vdagent/image.cpp
+++ b/vdagent/image.cpp
@@ -23,8 +23,6 @@
#include "image.h"
#include "imagepng.h"
-ImageCoder *create_bitmap_coder();
-
static ImageCoder *get_coder(uint32_t vdagent_type)
{
switch (vdagent_type) {
diff --git a/vdagent/image.h b/vdagent/image.h
index da549d3..326d7f9 100644
--- a/vdagent/image.h
+++ b/vdagent/image.h
@@ -39,6 +39,8 @@ static inline size_t compute_dib_stride(unsigned int width, unsigned int bit_cou
return ((width * bit_count + 31u) & ~31u) / 8u;
}
+ImageCoder *create_bitmap_coder();
+
/**
* Returns image to put in the clipboard.
*
diff --git a/vdagent/imagetest.cpp b/vdagent/imagetest.cpp
index 3a553a9..36b8f6c 100644
--- a/vdagent/imagetest.cpp
+++ b/vdagent/imagetest.cpp
@@ -18,6 +18,7 @@
#undef NDEBUG
#include <assert.h>
#include <vector>
+#include <memory>
#include "vdcommon.h"
#include "image.h"
@@ -42,7 +43,7 @@ save_dib_to_file(ImageCoder& coder, const uint8_t *raw_dib, const char *filename
int main(int argc, char **argv)
{
- ImageCoder *coder = create_png_coder();
+ std::unique_ptr<ImageCoder> coder(create_png_coder());
assert(coder);
if (argc < 2) {
@@ -68,19 +69,10 @@ int main(int argc, char **argv)
memset(&out[0], 0xcc, dib_size);
coder->get_dib_data(&out[0], &data[0], len);
- // looks like many tools wants this header so craft it
- BITMAPFILEHEADER head;
- memset(&head, 0, sizeof(head));
- head.bfType = 'B'+'M'*256u;
- head.bfSize = sizeof(head) + dib_size;
- BITMAPINFOHEADER& info(*(BITMAPINFOHEADER*)&out[0]);
- head.bfOffBits = sizeof(head) + sizeof(BITMAPINFOHEADER) + 4 * info.biClrUsed;
-
- f = fopen(argc > 2 ? argv[2] : "out.bmp", "wb");
- assert(f);
- assert(fwrite(&head, 1, sizeof(head), f) == sizeof(head));
- assert(fwrite(&out[0], 1, dib_size, f) == dib_size);
- fclose(f);
+ // write BMP file
+ std::unique_ptr<ImageCoder> bmp_coder(create_bitmap_coder());
+ assert(bmp_coder);
+ save_dib_to_file(*bmp_coder, &out[0], argc > 2 ? argv[2] : "out.bmp");
// convert back to PNG
save_dib_to_file(*coder, &out[0], argc > 3 ? argv[3] : "out.png");
--
2.17.1

View File

@ -1,26 +0,0 @@
From 2aa6f16af4ad2d50ab614dd87b10baae1729c461 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Thu, 24 May 2018 14:01:53 +0100
Subject: [PATCH 04/43] vdagent: Removed unused declaration
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/vdagent.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index f00fbf5..0a364df 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -99,7 +99,6 @@ private:
void dispatch_message(VDAgentMessage* msg, uint32_t port);
uint32_t get_clipboard_format(uint32_t type) const;
uint32_t get_clipboard_type(uint32_t format) const;
- DWORD get_cximage_format(uint32_t type) const;
enum { owner_none, owner_guest, owner_client };
void set_clipboard_owner(int new_owner);
enum { CONTROL_STOP, CONTROL_RESET, CONTROL_DESKTOP_SWITCH, CONTROL_LOGON, CONTROL_CLIPBOARD };
--
2.17.1

View File

@ -1,63 +0,0 @@
From e2ced9f094bf676856ae78779f4a791936eb535f Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Mon, 5 Sep 2016 14:51:56 +0100
Subject: [PATCH 05/43] Avoid to use names with reserved characters.
Some characters are reserved and should not be used in Windows
independently by the file system used.
This avoid to use paths in the filename which could lead to some
nasty hacks (like names like "..\hack.txt").
The return statement cause the file transfer to be aborted with
VD_AGENT_FILE_XFER_STATUS_ERROR as status.
":" is used to separate filenames from stream names and can be used
to create hidden streams. Also is used for drive separator (A:)
or device names (NUL:).
"/" and "\" are reserved for components (directory, filename, drive,
share, server) separators.
"*" and "?" are wildcards (which on Windows are supported by
different APIs too).
"<", ">", """ and "|" are reserved for shell usage.
More information on "Naming Files, Paths, and Namespaces" page at
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
This fixes also https://bugzilla.redhat.com/show_bug.cgi?id=1520393.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/file_xfer.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index e877cca..8203b99 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -33,6 +33,12 @@
#include "file_xfer.h"
#include "as_user.h"
+#define FILENAME_RESERVED_CHAR_LIST \
+ ":" /* streams and devices */ \
+ "/\\" /* components separator */ \
+ "?*" /* wildcards */ \
+ "<>\"|" /* reserved to shell */
+
void FileXfer::reset()
{
FileXferTasks::iterator iter;
@@ -72,6 +78,10 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
return;
}
vd_printf("%u %s (%" PRIu64 ")", start->id, file_name, file_size);
+ if (strcspn(file_name, FILENAME_RESERVED_CHAR_LIST) != strlen(file_name)) {
+ vd_printf("filename contains invalid characters");
+ return;
+ }
if (!as_user.begin()) {
vd_printf("as_user failed");
return;
--
2.17.1

View File

@ -1,92 +0,0 @@
From 9a929bd24ade5e25b33afd43509ff04acf4352a0 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Fri, 25 May 2018 19:47:20 +0100
Subject: [PATCH 08/43] vcproj: Remove reference to CxImage
Not used anymore.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/vdagent.vcproj | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/vdagent/vdagent.vcproj b/vdagent/vdagent.vcproj
index f9f4228..f830b0f 100644
--- a/vdagent/vdagent.vcproj
+++ b/vdagent/vdagent.vcproj
@@ -44,7 +44,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\common;$(SPICE_PROTOCOL_DIR);$(SPICE_LIBS)\include\CxImage"
+ AdditionalIncludeDirectories="..\common;$(SPICE_PROTOCOL_DIR)"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS,_WIN32_WINNT=0x0501"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -65,7 +65,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="Version.lib zlibwapiD.lib png_d.lib cximage_d.lib wtsapi32.lib"
+ AdditionalDependencies="Version.lib zlibwapiD.lib png_d.lib wtsapi32.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(SPICE_LIBS)\lib&quot;"
GenerateDebugInformation="true"
@@ -122,7 +122,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\common;$(SPICE_PROTOCOL_DIR);$(SPICE_LIBS)\include\CxImage"
+ AdditionalIncludeDirectories="..\common;$(SPICE_PROTOCOL_DIR)"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS,_WIN32_WINNT=0x0501"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -143,7 +143,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="Version.lib zlibwapiD.lib png_d.lib cximage_d.lib wtsapi32.lib"
+ AdditionalDependencies="Version.lib zlibwapiD.lib png_d.lib wtsapi32.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(SPICE_LIBS)\lib64&quot;"
IgnoreDefaultLibraryNames=""
@@ -200,7 +200,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\common;$(SPICE_PROTOCOL_DIR);$(SPICE_LIBS)\include\CxImage"
+ AdditionalIncludeDirectories="..\common;$(SPICE_PROTOCOL_DIR)"
AdditionalUsingDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS,_WIN32_WINNT=0x0501"
RuntimeLibrary="0"
@@ -220,7 +220,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="Version.lib zlibwapi.lib png.lib cximage.lib wtsapi32.lib"
+ AdditionalDependencies="Version.lib zlibwapi.lib png.lib wtsapi32.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SPICE_LIBS)\lib&quot;"
GenerateDebugInformation="true"
@@ -279,7 +279,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\common;$(SPICE_PROTOCOL_DIR);$(SPICE_LIBS)\include\CxImage"
+ AdditionalIncludeDirectories="..\common;$(SPICE_PROTOCOL_DIR)"
AdditionalUsingDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS,_WIN32_WINNT=0x0501"
RuntimeLibrary="0"
@@ -299,7 +299,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="Version.lib zlibwapi.lib png.lib cximage.lib wtsapi32.lib"
+ AdditionalDependencies="Version.lib zlibwapi.lib png.lib wtsapi32.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SPICE_LIBS)\lib64&quot;"
GenerateDebugInformation="true"
--
2.17.1

View File

@ -1,44 +0,0 @@
From b15a8806390153748594937f321c192181f9000f Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Fri, 25 May 2018 19:47:32 +0100
Subject: [PATCH 09/43] vcproj: Add some missing files
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/vdagent.vcproj | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/vdagent/vdagent.vcproj b/vdagent/vdagent.vcproj
index f830b0f..376ddd4 100644
--- a/vdagent/vdagent.vcproj
+++ b/vdagent/vdagent.vcproj
@@ -349,6 +349,10 @@
RelativePath=".\desktop_layout.cpp"
>
</File>
+ <File
+ RelativePath=".\display_configuration.cpp"
+ >
+ </File>
<File
RelativePath=".\display_setting.cpp"
>
@@ -357,6 +361,14 @@
RelativePath=".\file_xfer.cpp"
>
</File>
+ <File
+ RelativePath=".\image.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\imagepng.cpp"
+ >
+ </File>
<File
RelativePath=".\vdagent.cpp"
>
--
2.17.1

View File

@ -1,38 +0,0 @@
From 1982d50375e4f3fdf5d5ca5e497328743af4e559 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Sat, 26 May 2018 07:51:59 +0100
Subject: [PATCH 10/43] Fix minor compiler compatibility
Ensure std::min is declared including directly algorithm header.
Undefine possible min and max macros, some Windows headers define them.
Currently happens using Visual Studio 2015.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/image.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/vdagent/image.cpp b/vdagent/image.cpp
index 1b21b53..c0bcdb5 100644
--- a/vdagent/image.cpp
+++ b/vdagent/image.cpp
@@ -18,11 +18,15 @@
#include <spice/macros.h>
#include <memory>
#include <vector>
+#include <algorithm>
#include "vdcommon.h"
#include "image.h"
#include "imagepng.h"
+#undef max
+#undef min
+
static ImageCoder *get_coder(uint32_t vdagent_type)
{
switch (vdagent_type) {
--
2.17.1

View File

@ -1,29 +0,0 @@
From 022c56ac6ae2f7f9a082b81e44872d48aace35b2 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Sat, 26 May 2018 07:50:53 +0100
Subject: [PATCH 11/43] Avoid unused variable warning
Currently happens using Visual Studio 2015.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/display_configuration.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vdagent/display_configuration.cpp b/vdagent/display_configuration.cpp
index 6e7624b..cdbbe23 100644
--- a/vdagent/display_configuration.cpp
+++ b/vdagent/display_configuration.cpp
@@ -259,7 +259,7 @@ DisplayConfig* DisplayConfig::create_config()
try {
new_interface = new WDDMInterface();
}
- catch (std::exception& e) {
+ catch (std::exception&) {
new_interface = new XPDMInterface();
}
return new_interface;
--
2.17.1

View File

@ -1,61 +0,0 @@
From d4a4fb28ea0c057428ef1f28bc689b8d0f085dc6 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Mon, 28 May 2018 09:20:41 +0100
Subject: [PATCH 12/43] msi: Do not generate deps.txt
There's no reason to tell the package installed on the build system
used.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
Makefile.am | 5 +----
spice-vdagent.wxs.in | 4 ----
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 62640f2..3020824 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -100,15 +100,12 @@ test_log_win_SOURCES = \
common/test-log.cpp \
$(NULL)
-deps.txt:
- $(AM_V_GEN)rpm -qa | grep $(host_os) | sort | unix2dos > $@
-
MANUFACTURER = The Spice Project
EXTRA_DIST += spice-vdagent.wxs.in
CONFIG_STATUS_DEPENDENCIES = spice-vdagent.wxs.in
-spice-vdagent-$(WIXL_ARCH)-$(VERSION)$(BUILDID).msi: spice-vdagent.wxs deps.txt all
+spice-vdagent-$(WIXL_ARCH)-$(VERSION)$(BUILDID).msi: spice-vdagent.wxs all
$(AM_V_GEN)DESTDIR=`mktemp -d`&& \
make -C $(top_builddir) install DESTDIR=$$DESTDIR >/dev/null && \
MANUFACTURER="$(MANUFACTURER)" wixl -D SourceDir=$(prefix) \
diff --git a/spice-vdagent.wxs.in b/spice-vdagent.wxs.in
index 452f995..7432ca9 100644
--- a/spice-vdagent.wxs.in
+++ b/spice-vdagent.wxs.in
@@ -61,9 +61,6 @@
Wait="yes"/>
</Component>
</Directory>
- <Component Id="CDepsTxt" Guid="*">
- <File Id='depstxt' Name='deps.txt' DiskId='1' Source='deps.txt' KeyPath='yes'/>
- </Component>
</Directory>
</Directory>
</Directory>
@@ -71,7 +68,6 @@
<Feature Id="Complete" Level="1">
<ComponentRef Id="CSpiceAgent"/>
<ComponentRef Id="CSpiceService"/>
- <ComponentRef Id="CDepsTxt"/>
</Feature>
</Product>
--
2.17.1

View File

@ -1,39 +0,0 @@
From 0de788aa6175fa6035b9f79a7dcfda8b98cd1e6f Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Fri, 25 May 2018 19:41:26 +0100
Subject: [PATCH 13/43] file_xfer: Remove FileXferTask structure alignment
There's no reason beside losing performances to align
that structure, is not passed as binary data.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/file_xfer.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/vdagent/file_xfer.h b/vdagent/file_xfer.h
index 25cd5c2..029d0e7 100644
--- a/vdagent/file_xfer.h
+++ b/vdagent/file_xfer.h
@@ -21,7 +21,7 @@
#include <map>
#include "vdcommon.h"
-typedef struct ALIGN_VC FileXferTask {
+typedef struct FileXferTask {
FileXferTask(HANDLE _handle, uint64_t _size, const TCHAR* _name):
handle(_handle), size(_size), pos(0) {
// FIXME: should raise an error if name is too long..
@@ -36,7 +36,7 @@ typedef struct ALIGN_VC FileXferTask {
TCHAR name[MAX_PATH];
void cancel();
-} ALIGN_GCC FileXferTask;
+} FileXferTask;
typedef std::map<uint32_t, FileXferTask*> FileXferTasks;
--
2.17.1

View File

@ -1,39 +0,0 @@
From e8ab5856a116f6b7b9bd28781fcf2f685cc6645f Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Fri, 25 May 2018 19:46:34 +0100
Subject: [PATCH 14/43] file_xfer: Remove too C syntax for C++
In C++ simply declaring the struct add the structure name to the global
namespace, no needs for additional typedef.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/file_xfer.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/vdagent/file_xfer.h b/vdagent/file_xfer.h
index 029d0e7..747c29c 100644
--- a/vdagent/file_xfer.h
+++ b/vdagent/file_xfer.h
@@ -21,7 +21,7 @@
#include <map>
#include "vdcommon.h"
-typedef struct FileXferTask {
+struct FileXferTask {
FileXferTask(HANDLE _handle, uint64_t _size, const TCHAR* _name):
handle(_handle), size(_size), pos(0) {
// FIXME: should raise an error if name is too long..
@@ -36,7 +36,7 @@ typedef struct FileXferTask {
TCHAR name[MAX_PATH];
void cancel();
-} FileXferTask;
+};
typedef std::map<uint32_t, FileXferTask*> FileXferTasks;
--
2.17.1

View File

@ -1,99 +0,0 @@
From aefc220c027c98c0877cbb6dc7140e72f119262b Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Fri, 25 May 2018 20:01:11 +0100
Subject: [PATCH 15/43] file_xfer: Use destructor for FileXferTask
Limit too much manual work.
By default delete the file, unless success() is called.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/file_xfer.cpp | 24 +++++++++++++++---------
vdagent/file_xfer.h | 4 +++-
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index 8203b99..ff4c0b9 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -46,7 +46,6 @@ void FileXfer::reset()
for (iter = _tasks.begin(); iter != _tasks.end(); iter++) {
task = iter->second;
- task->cancel();
delete task;
}
_tasks.clear();
@@ -181,14 +180,11 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
return false;
}
vd_printf("%u completed", iter->first);
+ task->success();
status->result = VD_AGENT_FILE_XFER_STATUS_SUCCESS;
fin:
if (task) {
- CloseHandle(task->handle);
- if (status->result != VD_AGENT_FILE_XFER_STATUS_SUCCESS) {
- DeleteFile(task->name);
- }
_tasks.erase(iter);
delete task;
}
@@ -196,10 +192,21 @@ fin:
return true;
}
-void FileXferTask::cancel()
+FileXferTask::~FileXferTask()
{
- CloseHandle(handle);
- DeleteFile(name);
+ if (handle != INVALID_HANDLE_VALUE) {
+ CloseHandle(handle);
+ DeleteFile(name);
+ }
+}
+
+void FileXferTask::success()
+{
+ // close the handle so the destructor won't delete the file
+ if (handle != INVALID_HANDLE_VALUE) {
+ CloseHandle(handle);
+ handle = INVALID_HANDLE_VALUE;
+ }
}
void FileXfer::handle_status(VDAgentFileXferStatusMessage* status)
@@ -218,7 +225,6 @@ void FileXfer::handle_status(VDAgentFileXferStatusMessage* status)
return;
}
task = iter->second;
- task->cancel();
_tasks.erase(iter);
delete task;
}
diff --git a/vdagent/file_xfer.h b/vdagent/file_xfer.h
index 747c29c..41f677a 100644
--- a/vdagent/file_xfer.h
+++ b/vdagent/file_xfer.h
@@ -30,12 +30,14 @@ struct FileXferTask {
lstrcpyn(name, _name, ARRAYSIZE(name));
name[ARRAYSIZE(name)-1] = 0;
}
+ ~FileXferTask();
+
HANDLE handle;
uint64_t size;
uint64_t pos;
TCHAR name[MAX_PATH];
- void cancel();
+ void success();
};
typedef std::map<uint32_t, FileXferTask*> FileXferTasks;
--
2.17.1

View File

@ -1,130 +0,0 @@
From 7b0c48b15bfe3c02c4158c7cb213403739d078b5 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Fri, 25 May 2018 23:03:18 +0100
Subject: [PATCH 16/43] file_xfer: Use shared_ptr to simplify memory management
Clear automatically tasks items.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
vdagent/file_xfer.cpp | 25 ++++---------------------
vdagent/file_xfer.h | 3 ++-
2 files changed, 6 insertions(+), 22 deletions(-)
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index ff4c0b9..ada3b47 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -41,19 +41,11 @@
void FileXfer::reset()
{
- FileXferTasks::iterator iter;
- FileXferTask* task;
-
- for (iter = _tasks.begin(); iter != _tasks.end(); iter++) {
- task = iter->second;
- delete task;
- }
_tasks.clear();
}
FileXfer::~FileXfer()
{
- reset();
}
void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
@@ -63,7 +55,6 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
TCHAR file_path[MAX_PATH];
char file_name[MAX_PATH];
ULARGE_INTEGER free_bytes;
- FileXferTask* task;
uint64_t file_size;
HANDLE handle;
AsUser as_user;
@@ -146,7 +137,7 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
vd_printf("Failed creating %ls. More than 63 copies exist?", file_path);
return;
}
- task = new FileXferTask(handle, file_size, file_path);
+ auto task = std::make_shared<FileXferTask>(handle, file_size, file_path);
_tasks[start->id] = task;
status->result = VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA;
}
@@ -155,7 +146,6 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
VDAgentFileXferStatusMessage* status)
{
FileXferTasks::iterator iter;
- FileXferTask* task = NULL;
DWORD written;
status->id = data->id;
@@ -163,9 +153,9 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
iter = _tasks.find(data->id);
if (iter == _tasks.end()) {
vd_printf("file id %u not found", data->id);
- goto fin;
+ return true;
}
- task = iter->second;
+ auto task = iter->second;
task->pos += data->size;
if (task->pos > task->size) {
vd_printf("file xfer is longer than expected");
@@ -184,11 +174,7 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
status->result = VD_AGENT_FILE_XFER_STATUS_SUCCESS;
fin:
- if (task) {
- _tasks.erase(iter);
- delete task;
- }
-
+ _tasks.erase(iter);
return true;
}
@@ -212,7 +198,6 @@ void FileXferTask::success()
void FileXfer::handle_status(VDAgentFileXferStatusMessage* status)
{
FileXferTasks::iterator iter;
- FileXferTask* task;
vd_printf("id %u result %u", status->id, status->result);
if (status->result != VD_AGENT_FILE_XFER_STATUS_CANCELLED) {
@@ -224,9 +209,7 @@ void FileXfer::handle_status(VDAgentFileXferStatusMessage* status)
vd_printf("file id %u not found", status->id);
return;
}
- task = iter->second;
_tasks.erase(iter);
- delete task;
}
bool FileXfer::dispatch(VDAgentMessage* msg, VDAgentFileXferStatusMessage* status)
diff --git a/vdagent/file_xfer.h b/vdagent/file_xfer.h
index 41f677a..b138019 100644
--- a/vdagent/file_xfer.h
+++ b/vdagent/file_xfer.h
@@ -19,6 +19,7 @@
#define _H_FILE_XFER
#include <map>
+#include <memory>
#include "vdcommon.h"
struct FileXferTask {
@@ -40,7 +41,7 @@ struct FileXferTask {
void success();
};
-typedef std::map<uint32_t, FileXferTask*> FileXferTasks;
+typedef std::map<uint32_t, std::shared_ptr<FileXferTask> > FileXferTasks;
class FileXfer {
public:
--
2.17.1

View File

@ -1,257 +0,0 @@
From b291e4ca14b611ad20cb93d90dc98c8a715b91f9 Mon Sep 17 00:00:00 2001
From: "free.user.name" <free.user.name@ya.ru>
Date: Fri, 16 Feb 2018 15:05:39 +0300
Subject: [PATCH 17/43] vdagent: Fix loss of mouse movement events
send_input() may not be immediately called from handle_mouse_event() on
movement. INPUT structure is generated and stored and a timer may be set
instead. If subsequent call to handle_mouse_event() occurs before timer
expires, prepared INPUT structure gets overwritten and MOUSEEVENTF_MOVE
bit is lost. Windows doesn't see updated mouse position as the result.
Make handle_mouse_event() merely store the new mouse state, and move
INPUT structure generation to send_input(). Shuffle new mouse state to
previous only after mouse events are submitted to SendInput() Windows
API function.
This patch was sent to the mailing list by an anonymous contributor
with minimal style changes.
You can easily test increasing VD_INPUT_INTERVAL_MS (like 1000).
For instance you can try in a word processor to move the cursor
clicking the mouse on different positions.
Acked-by: Victor Toso <victortoso@redhat.com>
---
vdagent/vdagent.cpp | 145 +++++++++++++++++++++-----------------------
1 file changed, 70 insertions(+), 75 deletions(-)
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 0a364df..ca1f8fa 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -89,8 +89,7 @@ private:
void on_clipboard_grab();
void on_clipboard_request(UINT format);
void on_clipboard_release();
- DWORD get_buttons_change(DWORD last_buttons_state, DWORD new_buttons_state,
- DWORD mask, DWORD down_flag, DWORD up_flag);
+ DWORD get_buttons_change(DWORD mask, DWORD down_flag, DWORD up_flag);
static HGLOBAL utf8_alloc(LPCSTR data, int size);
static LRESULT CALLBACK wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
static DWORD WINAPI event_thread_proc(LPVOID param);
@@ -130,10 +129,8 @@ private:
int _system_version;
int _clipboard_owner;
DWORD _clipboard_tick;
- DWORD _buttons_state;
- ULONG _mouse_x;
- ULONG _mouse_y;
- INPUT _input;
+ VDAgentMouseState _new_mouse = {};
+ VDAgentMouseState _last_mouse = {};
DWORD _input_time;
HANDLE _control_event;
HANDLE _stop_event;
@@ -190,9 +187,6 @@ VDAgent::VDAgent()
, _remove_clipboard_listener (NULL)
, _clipboard_owner (owner_none)
, _clipboard_tick (0)
- , _buttons_state (0)
- , _mouse_x (0)
- , _mouse_y (0)
, _input_time (0)
, _control_event (NULL)
, _stop_event (NULL)
@@ -220,7 +214,6 @@ VDAgent::VDAgent()
swprintf_s(log_path, MAX_PATH, VD_AGENT_LOG_PATH, temp_path);
_log = VDLog::get(log_path);
}
- ZeroMemory(&_input, sizeof(_input));
ZeroMemory(&_read_overlapped, sizeof(_read_overlapped));
ZeroMemory(&_write_overlapped, sizeof(_write_overlapped));
ZeroMemory(_read_buf, sizeof(_read_buf));
@@ -521,113 +514,115 @@ void VDAgent::event_dispatcher(DWORD timeout, DWORD wake_mask)
}
}
-DWORD VDAgent::get_buttons_change(DWORD last_buttons_state, DWORD new_buttons_state,
- DWORD mask, DWORD down_flag, DWORD up_flag)
+DWORD VDAgent::get_buttons_change(DWORD mask, DWORD down_flag, DWORD up_flag)
{
DWORD ret = 0;
- if (!(last_buttons_state & mask) && (new_buttons_state & mask)) {
+ if (!(_last_mouse.buttons & mask) && (_new_mouse.buttons & mask)) {
ret = down_flag;
- } else if ((last_buttons_state & mask) && !(new_buttons_state & mask)) {
+ } else if ((_last_mouse.buttons & mask) && !(_new_mouse.buttons & mask)) {
ret = up_flag;
}
return ret;
}
bool VDAgent::send_input()
-{
- bool ret = true;
- _desktop_layout->lock();
- if (_pending_input) {
- if (KillTimer(_hwnd, VD_TIMER_ID)) {
- _pending_input = false;
- } else {
- vd_printf("KillTimer failed: %lu", GetLastError());
- _running = false;
- _desktop_layout->unlock();
- return false;
- }
- }
- if (!SendInput(1, &_input, sizeof(INPUT))) {
- DWORD err = GetLastError();
- // Don't stop agent due to UIPI blocking, which is usually only for specific windows
- // of system security applications (anti-viruses etc.)
- if (err != ERROR_SUCCESS && err != ERROR_ACCESS_DENIED) {
- vd_printf("SendInput failed: %lu", err);
- ret = _running = false;
- }
- }
- _input_time = GetTickCount();
- _desktop_layout->unlock();
- return ret;
-}
-
-bool VDAgent::handle_mouse_event(VDAgentMouseState* state)
{
DisplayMode* mode = NULL;
DWORD mouse_move = 0;
DWORD buttons_change = 0;
DWORD mouse_wheel = 0;
bool ret = true;
+ INPUT input;
+
+ if (_pending_input) {
+ if (KillTimer(_hwnd, VD_TIMER_ID)) {
+ _pending_input = false;
+ } else {
+ vd_printf("KillTimer failed: %lu", GetLastError());
+ _running = false;
+ return false;
+ }
+ }
ASSERT(_desktop_layout);
_desktop_layout->lock();
- if (state->display_id < _desktop_layout->get_display_count()) {
- mode = _desktop_layout->get_display(state->display_id);
+ if (_new_mouse.display_id < _desktop_layout->get_display_count()) {
+ mode = _desktop_layout->get_display(_new_mouse.display_id);
}
if (!mode || !mode->get_attached()) {
_desktop_layout->unlock();
return true;
}
- ZeroMemory(&_input, sizeof(INPUT));
- _input.type = INPUT_MOUSE;
- if (state->x != _mouse_x || state->y != _mouse_y) {
+ ZeroMemory(&input, sizeof(INPUT));
+ input.type = INPUT_MOUSE;
+ if (_new_mouse.x != _last_mouse.x || _new_mouse.y != _last_mouse.y) {
DWORD w = _desktop_layout->get_total_width();
DWORD h = _desktop_layout->get_total_height();
w = (w > 1) ? w-1 : 1; /* coordinates are 0..w-1, protect w==0 */
h = (h > 1) ? h-1 : 1; /* coordinates are 0..h-1, protect h==0 */
- _mouse_x = state->x;
- _mouse_y = state->y;
mouse_move = MOUSEEVENTF_MOVE;
- _input.mi.dx = (mode->get_pos_x() + _mouse_x) * 0xffff / w;
- _input.mi.dy = (mode->get_pos_y() + _mouse_y) * 0xffff / h;
+ input.mi.dx = (mode->get_pos_x() + _new_mouse.x) * 0xffff / w;
+ input.mi.dy = (mode->get_pos_y() + _new_mouse.y) * 0xffff / h;
}
- if (state->buttons != _buttons_state) {
- buttons_change = get_buttons_change(_buttons_state, state->buttons, VD_AGENT_LBUTTON_MASK,
+ if (_new_mouse.buttons != _last_mouse.buttons) {
+ buttons_change = get_buttons_change(VD_AGENT_LBUTTON_MASK,
MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP) |
- get_buttons_change(_buttons_state, state->buttons, VD_AGENT_MBUTTON_MASK,
+ get_buttons_change(VD_AGENT_MBUTTON_MASK,
MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP) |
- get_buttons_change(_buttons_state, state->buttons, VD_AGENT_RBUTTON_MASK,
+ get_buttons_change(VD_AGENT_RBUTTON_MASK,
MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP);
- mouse_wheel = get_buttons_change(_buttons_state, state->buttons,
- VD_AGENT_UBUTTON_MASK | VD_AGENT_DBUTTON_MASK,
+ mouse_wheel = get_buttons_change(VD_AGENT_UBUTTON_MASK | VD_AGENT_DBUTTON_MASK,
MOUSEEVENTF_WHEEL, 0);
if (mouse_wheel) {
- if (state->buttons & VD_AGENT_UBUTTON_MASK) {
- _input.mi.mouseData = WHEEL_DELTA;
- } else if (state->buttons & VD_AGENT_DBUTTON_MASK) {
- _input.mi.mouseData = (DWORD)(-WHEEL_DELTA);
+ if (_new_mouse.buttons & VD_AGENT_UBUTTON_MASK) {
+ input.mi.mouseData = WHEEL_DELTA;
+ } else if (_new_mouse.buttons & VD_AGENT_DBUTTON_MASK) {
+ input.mi.mouseData = (DWORD)(-WHEEL_DELTA);
}
}
- _buttons_state = state->buttons;
}
- _input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK | mouse_move |
- mouse_wheel | buttons_change;
+ input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK | mouse_move |
+ mouse_wheel | buttons_change;
- if ((mouse_move && GetTickCount() - _input_time > VD_INPUT_INTERVAL_MS) || buttons_change ||
- mouse_wheel) {
- ret = send_input();
- } else if (!_pending_input) {
- if (SetTimer(_hwnd, VD_TIMER_ID, VD_INPUT_INTERVAL_MS, NULL)) {
+ if (!SendInput(1, &input, sizeof(INPUT))) {
+ DWORD err = GetLastError();
+ // Don't stop agent due to UIPI blocking, which is usually only for specific windows
+ // of system security applications (anti-viruses etc.)
+ if (err != ERROR_SUCCESS && err != ERROR_ACCESS_DENIED) {
+ vd_printf("SendInput failed: %lu", err);
+ ret = _running = false;
+ }
+ } else {
+ _last_mouse = _new_mouse;
+ }
+ _input_time = GetTickCount();
+ _desktop_layout->unlock();
+ return ret;
+}
+
+bool VDAgent::handle_mouse_event(VDAgentMouseState* state)
+{
+ _new_mouse = *state;
+ if (_new_mouse.buttons != _last_mouse.buttons) {
+ return send_input();
+ }
+
+ if (_new_mouse.x != _last_mouse.x || _new_mouse.y != _last_mouse.y) {
+ if (GetTickCount() - _input_time > VD_INPUT_INTERVAL_MS) {
+ return send_input();
+ }
+
+ if (!_pending_input) {
+ if (!SetTimer(_hwnd, VD_TIMER_ID, VD_INPUT_INTERVAL_MS, NULL)) {
+ vd_printf("SetTimer failed: %lu", GetLastError());
+ _running = false;
+ return false;
+ }
_pending_input = true;
- } else {
- vd_printf("SetTimer failed: %lu", GetLastError());
- _running = false;
- ret = false;
}
}
- _desktop_layout->unlock();
- return ret;
+ return true;
}
bool VDAgent::handle_mon_config(VDAgentMonitorsConfig* mon_config, uint32_t port)
--
2.17.1

View File

@ -1,54 +0,0 @@
From 531dd85f60e3de8fd6deddc820f3f6a92d83186c Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Mon, 28 May 2018 10:50:14 +0100
Subject: [PATCH 18/43] Reuse spice-protocol macros instead of defining new
ones for alignment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
---
common/vdcommon.h | 8 --------
vdagent/vdagent.cpp | 6 ++++--
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/common/vdcommon.h b/common/vdcommon.h
index c1920e9..ac58efe 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -67,14 +67,6 @@ typedef Mutex mutex_t;
#define VD_AGENT_REGISTRY_KEY "SOFTWARE\\Red Hat\\Spice\\vdagent\\"
#define VD_AGENT_STOP_EVENT TEXT("Global\\vdagent_stop_event")
-#if defined __GNUC__
-#define ALIGN_GCC __attribute__ ((packed))
-#define ALIGN_VC
-#else
-#define ALIGN_GCC
-#define ALIGN_VC __declspec (align(1))
-#endif
-
/*
* Note: OLDMSVCRT, which is defined (in the Makefile) for mingw builds, and
* is not defined for Visual Studio builds.
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index ca1f8fa..e22687c 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -55,10 +55,12 @@ static const VDClipboardFormat clipboard_formats[] = {
#define clipboard_formats_count SPICE_N_ELEMENTS(clipboard_formats)
-typedef struct ALIGN_VC VDIChunk {
+#include <spice/start-packed.h>
+typedef struct SPICE_ATTR_PACKED VDIChunk {
VDIChunkHeader hdr;
uint8_t data[0];
-} ALIGN_GCC VDIChunk;
+} VDIChunk;
+#include <spice/end-packed.h>
#define VD_MESSAGE_HEADER_SIZE (sizeof(VDIChunk) + sizeof(VDAgentMessage))
#define VD_READ_BUF_SIZE (sizeof(VDIChunk) + VD_AGENT_MAX_DATA_SIZE)
--
2.17.1

View File

@ -1,29 +0,0 @@
From 14769f88c923945aba4aa257f9a8632a5b685210 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Tue, 29 May 2018 10:29:52 +0100
Subject: [PATCH 19/43] vdservice: Do not append line terminator to log
vd_printf already add a line terminator
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
---
vdservice/vdservice.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index ec6243e..7564fbb 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -337,7 +337,7 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
s->_status_handle = RegisterServiceCtrlHandlerEx(VD_SERVICE_NAME, &VDService::control_handler,
s);
if (!s->_status_handle) {
- vd_printf("RegisterServiceCtrlHandler failed\n");
+ vd_printf("RegisterServiceCtrlHandler failed");
return;
}
--
2.17.1

View File

@ -1,80 +0,0 @@
From 13fb63e328f799a4e87dc62f81f3d58faab6987c Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Fri, 25 May 2018 21:50:57 +0100
Subject: [PATCH 20/43] 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>
---
vdagent/display_setting.cpp | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/vdagent/display_setting.cpp b/vdagent/display_setting.cpp
index 25a248e..2b22144 100644
--- a/vdagent/display_setting.cpp
+++ b/vdagent/display_setting.cpp
@@ -285,7 +285,7 @@ bool DisplaySetting::disable_wallpaper()
bool DisplaySetting::reload_wallpaper(HKEY desktop_reg_key)
{
TCHAR wallpaper_path[MAX_PATH + 1];
- DWORD value_size = sizeof(wallpaper_path);
+ DWORD value_size = sizeof(wallpaper_path) - sizeof(wallpaper_path[0]);
DWORD value_type;
LONG status;
TCHAR cur_wallpaper[MAX_PATH + 1];
@@ -303,7 +303,8 @@ bool DisplaySetting::reload_wallpaper(HKEY desktop_reg_key)
return false;
}
- if (wallpaper_path[value_size - 1] != '\0') {
+ value_size /= sizeof(wallpaper_path[0]);
+ if (!value_size || wallpaper_path[value_size - 1] != '\0') {
wallpaper_path[value_size] = '\0';
}
@@ -339,7 +340,7 @@ bool DisplaySetting::disable_font_smoothing()
bool DisplaySetting::reload_font_smoothing(HKEY desktop_reg_key)
{
CHAR smooth_value[4];
- DWORD value_size = sizeof(smooth_value);
+ DWORD value_size = sizeof(smooth_value)-1;
DWORD value_type;
LONG status;
BOOL cur_font_smooth;
@@ -357,7 +358,7 @@ bool DisplaySetting::reload_font_smoothing(HKEY desktop_reg_key)
return false;
}
- if (smooth_value[value_size - 1] != '\0') {
+ if (!value_size || smooth_value[value_size - 1] != '\0') {
smooth_value[value_size] = '\0';
}
@@ -412,7 +413,7 @@ bool DisplaySetting::reload_win_animation(HKEY desktop_reg_key)
{
HKEY win_metrics_hkey;
CHAR win_anim_value[4];
- DWORD value_size = sizeof(win_anim_value);
+ DWORD value_size = sizeof(win_anim_value)-1;
DWORD value_type;
LONG status;
ANIMATIONINFO active_win_animation;
@@ -441,7 +442,7 @@ bool DisplaySetting::reload_win_animation(HKEY desktop_reg_key)
return false;
}
- if (win_anim_value[value_size - 1] != '\0') {
+ if (!value_size || win_anim_value[value_size - 1] != '\0') {
win_anim_value[value_size] = '\0';
}
--
2.17.1

View File

@ -1,62 +0,0 @@
From ae94c50ee912ab8925cda61449235a8027d49c77 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Wed, 30 May 2018 14:21:00 +0100
Subject: [PATCH 21/43] Use enumeration types
No reasons to allow any possible number.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
---
vdagent/vdagent.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index e22687c..551f326 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -100,10 +100,10 @@ private:
void dispatch_message(VDAgentMessage* msg, uint32_t port);
uint32_t get_clipboard_format(uint32_t type) const;
uint32_t get_clipboard_type(uint32_t format) const;
- enum { owner_none, owner_guest, owner_client };
- void set_clipboard_owner(int new_owner);
- enum { CONTROL_STOP, CONTROL_RESET, CONTROL_DESKTOP_SWITCH, CONTROL_LOGON, CONTROL_CLIPBOARD };
- void set_control_event(int control_command);
+ enum clipboard_owner_t { owner_none, owner_guest, owner_client };
+ void set_clipboard_owner(clipboard_owner_t new_owner);
+ enum control_command_t { CONTROL_STOP, CONTROL_RESET, CONTROL_DESKTOP_SWITCH, CONTROL_LOGON, CONTROL_CLIPBOARD };
+ void set_control_event(control_command_t control_command);
void handle_control_event();
VDIChunk* new_chunk(DWORD bytes = 0);
void enqueue_chunk(VDIChunk* msg);
@@ -346,7 +346,7 @@ void VDAgent::cleanup()
delete _desktop_layout;
}
-void VDAgent::set_control_event(int control_command)
+void VDAgent::set_control_event(control_command_t control_command)
{
MutexLocker lock(_control_mutex);
_control_queue.push(control_command);
@@ -1207,7 +1207,7 @@ uint32_t VDAgent::get_clipboard_type(uint32_t format) const
return 0;
}
-void VDAgent::set_clipboard_owner(int new_owner)
+void VDAgent::set_clipboard_owner(clipboard_owner_t new_owner)
{
// FIXME: Clear requests, clipboard data and state
if (new_owner == owner_none) {
@@ -1455,7 +1455,7 @@ LRESULT CALLBACK VDAgent::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARA
case WM_CLIPBOARDUPDATE:
case WM_DRAWCLIPBOARD:
if (a->_hwnd != GetClipboardOwner()) {
- a->set_clipboard_owner(a->owner_none);
+ a->set_clipboard_owner(owner_none);
a->on_clipboard_grab();
}
if (a->_hwnd_next_viewer) {
--
2.17.1

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Package Not Available
This package is not available on CentOS Stream 10.
It may be available on another branch.

1
dead.package Normal file
View File

@ -0,0 +1 @@
mingw-spice-vdagent package is retired on branch c10s for CS-2551