Skip to contentSkip to conversation

libcldc: correct length checks in open_end_cb

PATCH Applied Pete Zaitcev 2 participants 2 messages Aug 12, 2009 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libcldc: correct length checks in open_end_cb

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.

lib/cldc.c +6 -4
index 072c995..6e1d826 100644
@@ -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;
 	}
Applied
#1 lore raw
Quoted 5 lines · Pete Zaitcev

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.

applied