All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch] libcldc: correct length checks in open_end_cb
Date: Tue, 11 Aug 2009 23:28:35 -0600	[thread overview]
Message-ID: <20090811232835.73055227@redhat.com> (raw)

Without this patch, open errors cannot be delivered to application
and opens get stuck forever. Also, who added -EINVAL again?! Stop
doing that, the user wants to know what failed: syscall or CLD protocol.

Signed-Off-By: Pete Zaitcev <zaitcev@redhat.com>

diff --git a/lib/cldc.c b/lib/cldc.c
index 072c995..6e1d826 100644
--- a/lib/cldc.c
+++ b/lib/cldc.c
@@ -1001,15 +1001,17 @@ static ssize_t open_end_cb(struct cldc_msg *msg, const void *resp_p,
 	struct cldc_fh *fh = msg->cb_private;
 	enum cle_err_codes resp_rc = CLE_OK;
 
-	if (resp_len < sizeof(*resp))
-		return -EINVAL;
-
 	if (!ok)
 		resp_rc = CLE_TIMEOUT;
-	else
+	else {
+		if (resp_len < sizeof(resp->resp))
+			return -1009;
 		resp_rc = le32_to_cpu(resp->resp.code);
+	}
 
 	if (resp_rc == CLE_OK) {
+		if (resp_len < sizeof(*resp))
+			return -1010;
 		fh->fh_le = resp->fh;
 		fh->valid = true;
 	}

             reply	other threads:[~2009-08-12  5:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-12  5:28 Pete Zaitcev [this message]
2009-08-12 10:05 ` [Patch] libcldc: correct length checks in open_end_cb Jeff Garzik

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=20090811232835.73055227@redhat.com \
    --to=zaitcev@redhat.com \
    --cc=hail-devel@vger.kernel.org \
    --cc=jeff@garzik.org \
    /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.