All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabio M. Di Nitto <fdinitto@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] qdisk - memcpy incorrect(?)
Date: Thu, 16 May 2013 20:22:20 +0200	[thread overview]
Message-ID: <519523DC.5030304@redhat.com> (raw)
In-Reply-To: <CDBA96EF.25FB7%neale@sinenomine.net>

This is already fixed in more recent releases. See commit:

8edb0d0eb31d94b8a3ba81f6d5b4c398accc950d

your patch also misses another incorrect in diskRawWrite.

Fabio

On 05/16/2013 08:00 PM, Neale Ferguson wrote:
> Hi,
>  In diskRawRead in disk.c there is the following code:
> 
>        readret = posix_memalign((void **)&alignedBuf, disk->d_pagesz,
> disk->d_blksz);
>         if (readret < 0) {
>                 return -1;
>         }
> 
>         io_state(STATE_READ);
>         readret = read(disk->d_fd, alignedBuf, readlen);
>         io_state(STATE_NONE);
>         if (readret > 0) {
>                 if (readret > len) {
>                         memcpy(alignedBuf, buf, len);
>                         readret = len;
>                 } else {
>                         memcpy(alignedBuf, buf, readret);
>                 }
>         }
> 
>         free(alignedBuf);
> 
> The memcpy() above have the src/dst operands swapped. We read into
> alignedBuf and are supposed to copy to buf. I?m not sure why qdiskd
> works sometimes and not others.  
> 
> --- cluster-3.0.12.1/cman/qdisk/disk.c    2013/05/16 16:45:49    1.1
> +++ cluster-3.0.12.1/cman/qdisk/disk.c    2013/05/16 16:46:29
> @@ -430,14 +430,14 @@
>      io_state(STATE_READ);
>      readret = read(disk->d_fd, alignedBuf, readlen);
>      io_state(STATE_NONE);
>      if (readret > 0) {
>          if (readret > len) {
> -            memcpy(alignedBuf, buf, len);
> +            memcpy(buf, alignedBuf, len);
>              readret = len;
>          } else {
> -            memcpy(alignedBuf, buf, readret);
> +            memcpy(buf, alignedBuf, readret);
>          }
>      }
>  
>      free(alignedBuf);
>      if (readret != len) {
> 
> Neale



      reply	other threads:[~2013-05-16 18:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-16 18:00 [Cluster-devel] qdisk - memcpy incorrect(?) Neale Ferguson
2013-05-16 18:22 ` Fabio M. Di Nitto [this message]

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=519523DC.5030304@redhat.com \
    --to=fdinitto@redhat.com \
    /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.