[Spice-commits] 5 commits - vdagent/display_setting.cpp vdagent/file_xfer.cpp vdagent/image.cpp vdagent/image.h vdagent/imagepng.cpp vdagent/imagetest.cpp vdagent/vdagent.cpp
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Mar 30 13:02:07 UTC 2020
vdagent/display_setting.cpp | 2 +-
vdagent/file_xfer.cpp | 2 +-
vdagent/image.cpp | 6 +++---
vdagent/image.h | 4 ++--
vdagent/imagepng.cpp | 6 +++---
vdagent/imagetest.cpp | 2 +-
vdagent/vdagent.cpp | 5 +++--
7 files changed, 14 insertions(+), 13 deletions(-)
New commits:
commit 57266085b9d68474f4006e09dece5945e5f8cc82
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Mar 23 14:13:48 2020 +0000
try to remove other bugs
diff --git a/vdagent/imagepng.cpp b/vdagent/imagepng.cpp
index a0d4cdd..1cc8ec6 100644
--- a/vdagent/imagepng.cpp
+++ b/vdagent/imagepng.cpp
@@ -36,7 +36,7 @@ private:
struct ReadBufferIo {
const uint8_t *buf;
- uint32_t pos, size;
+ size_t pos, size;
ReadBufferIo(const uint8_t *_buf, uint32_t _size):
buf(_buf), pos(0), size(_size)
{}
commit 8e4037706841a89915ccb0db84e4b336433027eb
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Mar 23 13:56:17 2020 +0000
try to fix previous
diff --git a/vdagent/image.cpp b/vdagent/image.cpp
index e4adcd9..56612d3 100644
--- a/vdagent/image.cpp
+++ b/vdagent/image.cpp
@@ -64,7 +64,7 @@ HANDLE get_image_handle(const VDAgentClipboard& clipboard, uint32_t size, UINT&
}
uint8_t* get_raw_clipboard_image(const VDAgentClipboardRequest& clipboard_request,
- HANDLE clip_data, ssize_t& new_size)
+ HANDLE clip_data, intptr_t& new_size)
{
new_size = 0;
@@ -133,7 +133,7 @@ public:
BitmapCoder() {};
size_t get_dib_size(const uint8_t *data, size_t size);
void get_dib_data(uint8_t *dib, const uint8_t *data, size_t size);
- uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, ssize_t &size);
+ uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, intptr_t&size);
};
size_t BitmapCoder::get_dib_size(const uint8_t *data, size_t size)
@@ -150,7 +150,7 @@ void BitmapCoder::get_dib_data(uint8_t *dib, const uint8_t *data, size_t size)
memcpy(dib, data + (size - new_size), new_size);
}
-uint8_t *BitmapCoder::from_bitmap(const BITMAPINFO& info, const void *bits, ssize_t &size)
+uint8_t *BitmapCoder::from_bitmap(const BITMAPINFO& info, const void *bits, intptr_t&size)
{
BITMAPFILEHEADER file_hdr;
diff --git a/vdagent/image.h b/vdagent/image.h
index 29466bf..21d8922 100644
--- a/vdagent/image.h
+++ b/vdagent/image.h
@@ -25,7 +25,7 @@ public:
virtual ~ImageCoder() {}
virtual size_t get_dib_size(const uint8_t *data, size_t size)=0;
virtual void get_dib_data(uint8_t *dib, const uint8_t *data, size_t size)=0;
- virtual uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, ssize_t &size)=0;
+ virtual uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, intptr_t&size)=0;
private:
ImageCoder(const ImageCoder& rhs);
void operator=(const ImageCoder &rhs);
@@ -61,7 +61,7 @@ HANDLE get_image_handle(const VDAgentClipboard& clipboard, uint32_t size, UINT&
* @param[out] new_size size of returned data
*/
uint8_t* get_raw_clipboard_image(const VDAgentClipboardRequest& clipboard_request,
- HANDLE clip_data, ssize_t& new_size);
+ HANDLE clip_data, intptr_t& new_size);
/**
* Free data returned by get_raw_clipboard_image
diff --git a/vdagent/imagepng.cpp b/vdagent/imagepng.cpp
index 8f22d6c..a0d4cdd 100644
--- a/vdagent/imagepng.cpp
+++ b/vdagent/imagepng.cpp
@@ -29,7 +29,7 @@ public:
PngCoder() {};
size_t get_dib_size(const uint8_t *data, size_t size);
void get_dib_data(uint8_t *dib, const uint8_t *data, size_t size);
- uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, ssize_t &size);
+ uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, intptr_t&size);
private:
size_t convert_to_dib(uint8_t *out_buf, const uint8_t *data, size_t size);
};
@@ -271,7 +271,7 @@ void PngCoder::get_dib_data(uint8_t *dib, const uint8_t *data, size_t size)
convert_to_dib(dib, data, size);
}
-uint8_t *PngCoder::from_bitmap(const BITMAPINFO& bmp_info, const void *bits, ssize_t &size)
+uint8_t *PngCoder::from_bitmap(const BITMAPINFO& bmp_info, const void *bits, intptr_t&size)
{
// this vector is here to avoid leaking resources if libpng use setjmp/longjmp
std::vector<png_color> palette;
diff --git a/vdagent/imagetest.cpp b/vdagent/imagetest.cpp
index 36b8f6c..e9ccb47 100644
--- a/vdagent/imagetest.cpp
+++ b/vdagent/imagetest.cpp
@@ -30,7 +30,7 @@ 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;
+ intptr_t size = 0;
uint8_t *raw_file = coder.from_bitmap(info, raw_bits, size);
assert(raw_file && size > 0);
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 730b914..5d2fdcb 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -1102,7 +1102,7 @@ bool VDAgent::handle_clipboard_request(const VDAgentClipboardRequest* clipboard_
UINT format;
HANDLE clip_data;
uint8_t* new_data = NULL;
- ssize_t new_size = 0;
+ intptr_t new_size = 0;
size_t len = 0;
VDAgentClipboard* clipboard = NULL;
@@ -1145,7 +1145,7 @@ bool VDAgent::handle_clipboard_request(const VDAgentClipboardRequest* clipboard_
}
if ((_max_clipboard != -1) && (new_size > _max_clipboard)) {
vd_printf("clipboard is too large (%" PRIdPTR " > %d), discarding",
- (intptr_t) new_size, _max_clipboard);
+ new_size, _max_clipboard);
goto handle_clipboard_request_fail;
}
commit 66b6933a388b222cb9ffa510401bf2485d4e6f2e
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Mar 23 13:38:40 2020 +0000
attempt to fix more warnings!
diff --git a/vdagent/image.cpp b/vdagent/image.cpp
index c0bcdb5..e4adcd9 100644
--- a/vdagent/image.cpp
+++ b/vdagent/image.cpp
@@ -64,7 +64,7 @@ HANDLE get_image_handle(const VDAgentClipboard& clipboard, uint32_t size, UINT&
}
uint8_t* get_raw_clipboard_image(const VDAgentClipboardRequest& clipboard_request,
- HANDLE clip_data, long& new_size)
+ HANDLE clip_data, ssize_t& new_size)
{
new_size = 0;
@@ -133,7 +133,7 @@ public:
BitmapCoder() {};
size_t get_dib_size(const uint8_t *data, size_t size);
void get_dib_data(uint8_t *dib, const uint8_t *data, size_t size);
- uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, long &size);
+ uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, ssize_t &size);
};
size_t BitmapCoder::get_dib_size(const uint8_t *data, size_t size)
@@ -150,7 +150,7 @@ void BitmapCoder::get_dib_data(uint8_t *dib, const uint8_t *data, size_t size)
memcpy(dib, data + (size - new_size), new_size);
}
-uint8_t *BitmapCoder::from_bitmap(const BITMAPINFO& info, const void *bits, long &size)
+uint8_t *BitmapCoder::from_bitmap(const BITMAPINFO& info, const void *bits, ssize_t &size)
{
BITMAPFILEHEADER file_hdr;
diff --git a/vdagent/image.h b/vdagent/image.h
index 326d7f9..29466bf 100644
--- a/vdagent/image.h
+++ b/vdagent/image.h
@@ -25,7 +25,7 @@ public:
virtual ~ImageCoder() {}
virtual size_t get_dib_size(const uint8_t *data, size_t size)=0;
virtual void get_dib_data(uint8_t *dib, const uint8_t *data, size_t size)=0;
- virtual uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, long &size)=0;
+ virtual uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, ssize_t &size)=0;
private:
ImageCoder(const ImageCoder& rhs);
void operator=(const ImageCoder &rhs);
@@ -61,7 +61,7 @@ HANDLE get_image_handle(const VDAgentClipboard& clipboard, uint32_t size, UINT&
* @param[out] new_size size of returned data
*/
uint8_t* get_raw_clipboard_image(const VDAgentClipboardRequest& clipboard_request,
- HANDLE clip_data, long& new_size);
+ HANDLE clip_data, ssize_t& new_size);
/**
* Free data returned by get_raw_clipboard_image
diff --git a/vdagent/imagepng.cpp b/vdagent/imagepng.cpp
index 78b4188..8f22d6c 100644
--- a/vdagent/imagepng.cpp
+++ b/vdagent/imagepng.cpp
@@ -29,7 +29,7 @@ public:
PngCoder() {};
size_t get_dib_size(const uint8_t *data, size_t size);
void get_dib_data(uint8_t *dib, const uint8_t *data, size_t size);
- uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, long &size);
+ uint8_t *from_bitmap(const BITMAPINFO& info, const void *bits, ssize_t &size);
private:
size_t convert_to_dib(uint8_t *out_buf, const uint8_t *data, size_t size);
};
@@ -271,7 +271,7 @@ void PngCoder::get_dib_data(uint8_t *dib, const uint8_t *data, size_t size)
convert_to_dib(dib, data, size);
}
-uint8_t *PngCoder::from_bitmap(const BITMAPINFO& bmp_info, const void *bits, long &size)
+uint8_t *PngCoder::from_bitmap(const BITMAPINFO& bmp_info, const void *bits, ssize_t &size)
{
// this vector is here to avoid leaking resources if libpng use setjmp/longjmp
std::vector<png_color> palette;
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index df794b8..730b914 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -28,6 +28,7 @@
#include <queue>
#include <set>
#include <vector>
+#include <cinttypes>
#define VD_AGENT_LOG_PATH TEXT("%svdagent.log")
#define VD_AGENT_WINCLASS_NAME TEXT("VDAGENT")
@@ -1101,7 +1102,7 @@ bool VDAgent::handle_clipboard_request(const VDAgentClipboardRequest* clipboard_
UINT format;
HANDLE clip_data;
uint8_t* new_data = NULL;
- long new_size = 0;
+ ssize_t new_size = 0;
size_t len = 0;
VDAgentClipboard* clipboard = NULL;
@@ -1143,8 +1144,8 @@ bool VDAgent::handle_clipboard_request(const VDAgentClipboardRequest* clipboard_
goto handle_clipboard_request_fail;
}
if ((_max_clipboard != -1) && (new_size > _max_clipboard)) {
- vd_printf("clipboard is too large (%ld > %d), discarding",
- new_size, _max_clipboard);
+ vd_printf("clipboard is too large (%" PRIdPTR " > %d), discarding",
+ (intptr_t) new_size, _max_clipboard);
goto handle_clipboard_request_fail;
}
commit c8fd498b7fd329cdbd5a74a76cd7f0d56ba55043
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Mar 23 12:36:20 2020 +0000
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 at redhat.com>
diff --git a/vdagent/display_setting.cpp b/vdagent/display_setting.cpp
index b6711d7..1d66048 100644
--- a/vdagent/display_setting.cpp
+++ b/vdagent/display_setting.cpp
@@ -290,7 +290,7 @@ bool DisplaySetting::disable_wallpaper()
static bool RegReadString(HKEY key, const TCHAR *name, TCHAR *buffer, size_t buffer_len)
{
- DWORD value_size = buffer_len * sizeof(buffer[0]);
+ DWORD value_size = (DWORD) (buffer_len * sizeof(buffer[0]));
DWORD value_type;
LONG status;
commit f920c23e2ed3b0e0b773688dd154e5d3ba1cf84b
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Mar 23 12:17:11 2020 +0000
file_xfer: Remove a warning
Avoids:
warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index bbaa085..016bd4e 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -86,7 +86,7 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
uint64_t file_size;
HANDLE handle;
AsUser as_user;
- int wlen;
+ size_t wlen;
status->id = start->id;
status->result = VD_AGENT_FILE_XFER_STATUS_ERROR;
More information about the Spice-commits
mailing list