All of lore.kernel.org
 help / color / mirror / Atom feed
* multipath-tools: Fix rtpg buffer length calculation
@ 2009-09-02 19:40 Benjamin Marzinski
  0 siblings, 0 replies; only message in thread
From: Benjamin Marzinski @ 2009-09-02 19:40 UTC (permalink / raw)
  To: device-mapper development

Since you use scsi_buflen to allocate the correct size for the
SCSI RTPG request buffer, You need to have the "+4" in its
calculation, not just in the check to see if the request buffer is
already big enough, otherwise, you'll fail the check, but you
won't allocate a new buffer that is big enough.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/prioritizers/alua_rtpg.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: multipath-tools-090902/libmultipath/prioritizers/alua_rtpg.c
===================================================================
--- multipath-tools-090902.orig/libmultipath/prioritizers/alua_rtpg.c
+++ multipath-tools-090902/libmultipath/prioritizers/alua_rtpg.c
@@ -267,8 +267,8 @@ get_asymmetric_access_state(int fd, unsi
 	rc = do_rtpg(fd, buf, buflen);
 	if (rc < 0)
 		return rc;
-	scsi_buflen = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
-	if (buflen < (scsi_buflen + 4)) {
+	scsi_buflen = (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) + 4;
+	if (buflen < scsi_buflen) {
 		free(buf);
 		buf = (unsigned char *)malloc(scsi_buflen);
 		if (!buf) {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-02 19:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-02 19:40 multipath-tools: Fix rtpg buffer length calculation Benjamin Marzinski

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.