* [Cluster-devel] qdisk - memcpy incorrect(?)
@ 2013-05-16 18:00 Neale Ferguson
2013-05-16 18:22 ` Fabio M. Di Nitto
0 siblings, 1 reply; 2+ messages in thread
From: Neale Ferguson @ 2013-05-16 18:00 UTC (permalink / raw)
To: cluster-devel.redhat.com
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20130516/0b181dfb/attachment.htm>
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Cluster-devel] qdisk - memcpy incorrect(?)
2013-05-16 18:00 [Cluster-devel] qdisk - memcpy incorrect(?) Neale Ferguson
@ 2013-05-16 18:22 ` Fabio M. Di Nitto
0 siblings, 0 replies; 2+ messages in thread
From: Fabio M. Di Nitto @ 2013-05-16 18:22 UTC (permalink / raw)
To: cluster-devel.redhat.com
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-16 18:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-16 18:00 [Cluster-devel] qdisk - memcpy incorrect(?) Neale Ferguson
2013-05-16 18:22 ` Fabio M. Di Nitto
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.