Re: [PATCH spice-gtk] channel-display: fix bug when sending preferred video codecs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> The transfer between the codecs array and the message payload cannot
> be done with memcpy because the data-types are different
> (gint/uint8_t).
> 
> Signed-off-by: Kevin Pouget <kpouget@xxxxxxxxxx>

Acked

> ---
>  src/channel-display.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/channel-display.c b/src/channel-display.c
> index 44555e3..59c809d 100644
> --- a/src/channel-display.c
> +++ b/src/channel-display.c
> @@ -615,11 +615,17 @@ static void
> spice_display_send_client_preferred_video_codecs(SpiceChannel *chann
>  {
>      SpiceMsgOut *out;
>      SpiceMsgcDisplayPreferredVideoCodecType *msg;
> +    int i;
> 
>      msg = g_malloc0(sizeof(SpiceMsgcDisplayPreferredVideoCodecType) +
> -                    (sizeof(SpiceVideoCodecType) * ncodecs));
> +                    (sizeof(msg->codecs[0]) * ncodecs));
>      msg->num_of_codecs = ncodecs;
> -    memcpy(msg->codecs, codecs, sizeof(*codecs) * ncodecs);
> +
> +    /* cannot memcpy because codecs is gint, but msg->codecs is uint8_t
> +     * but safe because SpiceVideoCodecType <= 255 */
> +    for (i = 0; i < ncodecs; i++) {
> +        msg->codecs[i] = codecs[i];
> +    }
> 
>      out = spice_msg_out_new(channel,
>      SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE);
>      out->marshallers->msgc_display_preferred_video_codec_type(out->marshaller,
>      msg);
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]