All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Clemens Ladisch <clemens@ladisch.de>,
	Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH] rawmidi: virtual: fix reading into a small buffer
Date: Sun, 19 Mar 2017 15:23:11 +0900	[thread overview]
Message-ID: <f1a2ca77-78d6-538c-bc06-6c770a99a8e8@sakamocchi.jp> (raw)
In-Reply-To: <b91aca79-8808-0cc4-ff3b-ad7ea16dec4b@ladisch.de>

Hi,

On Mar 19 2017 07:10, Clemens Ladisch wrote:
> In the special case for handling partial messages, the pointer
> calculations were wrong, which would result in data corruption.
>
> Signed-off-by: Clemens Ladisch <clemens@ladisch.de>

Reviewd-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

> --- alsa-lib/src/rawmidi/rawmidi_virt.c
> +++ alsa-lib/src/rawmidi/rawmidi_virt.c
> @@ -263,8 +263,8 @@ static ssize_t snd_rawmidi_virtual_read(snd_rawmidi_t *rmidi, void *buffer, size
>  		}
>  		size1 = virt->in_buf_size - virt->in_buf_ofs;
>  		if ((size_t)size1 > size) {
> -			virt->in_buf_ofs += size1 - size;
> -			memcpy(buffer, virt->in_buf_ptr, size);
> +			memcpy(buffer, virt->in_buf_ptr + virt->in_buf_ofs, size);
> +			virt->in_buf_ofs += size;
>  			result += size;
>  			break;
>  		}


Regards

Takashi Sakamoto

  reply	other threads:[~2017-03-19  6:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-18 22:10 [PATCH] rawmidi: virtual: fix reading into a small buffer Clemens Ladisch
2017-03-19  6:23 ` Takashi Sakamoto [this message]
2017-03-20  9:35 ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1a2ca77-78d6-538c-bc06-6c770a99a8e8@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.