[Spice-commits] vdagent/file_xfer.cpp

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu May 18 10:05:29 UTC 2017


 vdagent/file_xfer.cpp |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 3b1d9ab0a02d1b52e36c2d9b36dbde16b08d5ca5
Author: Jakub Janků <janku.jakub.jj at gmail.com>
Date:   Wed May 17 22:47:42 2017 +0200

    Use sprintf_s instead of sprintf to not crash
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index de1aea1..e877cca 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -113,8 +113,8 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
         if (attempt == 0) {
             strcpy(dest_filename, file_name);
         } else {
-            sprintf(dest_filename, "%.*s (%d)%s", int(extension - file_name), file_name,
-                    attempt, extension);
+            sprintf_s(dest_filename, SPICE_N_ELEMENTS(dest_filename),
+                      "%.*s (%d)%s", int(extension - file_name), file_name, attempt, extension);
         }
         if ((MultiByteToWideChar(CP_UTF8, 0, dest_filename, -1, file_path + wlen, MAX_PATH - wlen)) == 0) {
             vd_printf("failed converting file_name:%s to WideChar", dest_filename);


More information about the Spice-commits mailing list