[Spice-commits] vdagent/file_xfer.cpp

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 6 09:44:02 UTC 2019


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

New commits:
commit 1da442ad736c070691f9221a4b28ca996f487cdc
Author: Uri Lublin <uril at redhat.com>
Date:   Mon Feb 25 12:20:06 2019 +0200

    file-xfer: handle_start: use snprintf instead of sprintf_s
    
    When building with older mingw, sprintf_s does not
    always work as expected, but snprintf does.
    
    Also it's more consistent in the file.
    
    Note that when building with VS, snprintf becomes sprintf_s
    
    Related: rhbz#1410181
    
    Signed-off-by: Uri Lublin <uril at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index d158006..bbaa085 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -139,8 +139,8 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
         if (attempt == 0) {
             strcpy(dest_filename, file_name);
         } else {
-            sprintf_s(dest_filename, SPICE_N_ELEMENTS(dest_filename),
-                      "%.*s (%d)%s", int(extension - file_name), file_name, attempt, extension);
+            snprintf(dest_filename, sizeof(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