[Spice-devel] [vdagent-win 2/3] Use new vdagent_{strncpy, strcat}_s helpers

Uri Lublin uril at redhat.com
Thu Mar 19 04:46:22 PDT 2015


On 02/16/2015 12:28 PM, Christophe Fergeau wrote:
> ---
>   vdagent/file_xfer.cpp | 4 ++--
>   vdagent/file_xfer.h   | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
> index 8d7c86c..9e0bcda 100644
> --- a/vdagent/file_xfer.cpp
> +++ b/vdagent/file_xfer.cpp
> @@ -87,8 +87,8 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
>           return;
>       }
>
> -    strcat(file_path, "\\");
> -    strcat(file_path, file_name);
> +    vdagent_strcat_s(file_path, sizeof(file_path), "\\");
> +    vdagent_strcat_s(file_path, sizeof(file_path), file_name);
>       if((wlen = MultiByteToWideChar(CP_UTF8, 0, file_path, -1, NULL, 0)) == 0){
>           vd_printf("failed getting WideChar length of %s", file_path);
>           return;
> diff --git a/vdagent/file_xfer.h b/vdagent/file_xfer.h
> index 07a6808..7f756e3 100644
> --- a/vdagent/file_xfer.h
> +++ b/vdagent/file_xfer.h
> @@ -27,7 +27,7 @@ typedef struct ALIGN_VC FileXferTask {
>           // FIXME: should raise an error if name is too long..
>           //        currently the only user is FileXfer::handle_start
>           //        which verifies that strlen(_name) < MAX_PATH
> -        strncpy(name, _name, sizeof(name) - 1);
> +        vdagent_strncpy_s(name, sizeof(name), _name);

This should be vdagent_strcpy_s

>       }
>       HANDLE handle;
>       uint64_t size;
>



More information about the Spice-devel mailing list