From: Dan Carpenter <dan.carpenter@oracle.com>
To: KY Srinivasan <kys@microsoft.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"ohering@suse.com" <ohering@suse.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"virtualization@lists.osdl.org" <virtualization@lists.osdl.org>,
Alan Stern <stern@rowland.harvard.edu>,
"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>
Subject: Re: [PATCH 2/4] Drivers: hv: Support the newly introduced KVP messages in the driver
Date: Mon, 12 Mar 2012 16:03:53 +0300 [thread overview]
Message-ID: <20120312130353.GF3337@mwanda> (raw)
In-Reply-To: <6E21E5352C11B742B20C142EB499E0481B75D4CE@TK5EX14MBXC122.redmond.corp.microsoft.com>
[-- Attachment #1: Type: text/plain, Size: 2195 bytes --]
On Mon, Mar 12, 2012 at 12:36:53PM +0000, KY Srinivasan wrote:
> Dan,
> I am sorry for not being as precise as I should be:
> utf16s_to_utf8s() takes two length parameters - the length of the utf16 string
> that is to be converted and the second the length of the utf8 output string.
> The windows host manipulates all string in utf16 encoding and the string we get
> from the host is guaranteed to be less than or equal to MAX value that we have
> including the terminating character. In my code, I simply pass the length of the
> utf16 string as received from the host.
>
> The parameter that I am currently passing MAX length value is the "maxout"
> parameter of the utf16s_utf8s() function. This by definition is the size of the
> output buffer and in this case it happens to be MAX characters big.
>
I also think I'm not being as clear as I should... I understand
that you trust the input; I'm say that for correctness sake you
should specify a output size which leaves room for the NUL char.
I can't say I know this code very well so I could be wrong, but it's
what we do inside usb_string() for example. Can someone who knows
the code check if we should do something like this:
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index 3b2eeaa..3a97f52 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -173,7 +173,7 @@ kvp_send_key(struct work_struct *dummy)
in_msg->body.kvp_set.data.value_size,
UTF16_LITTLE_ENDIAN,
message->body.kvp_set.data.value,
- HV_KVP_EXCHANGE_MAX_VALUE_SIZE) + 1;
+ HV_KVP_EXCHANGE_MAX_VALUE_SIZE - 1) + 1;
break;
case REG_U32:
@@ -208,7 +208,7 @@ kvp_send_key(struct work_struct *dummy)
in_msg->body.kvp_set.data.key_size,
UTF16_LITTLE_ENDIAN,
message->body.kvp_set.data.key,
- HV_KVP_EXCHANGE_MAX_KEY_SIZE) + 1;
+ HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1;
break;
@@ -219,7 +219,7 @@ kvp_send_key(struct work_struct *dummy)
in_msg->body.kvp_delete.key_size,
UTF16_LITTLE_ENDIAN,
message->body.kvp_delete.key,
- HV_KVP_EXCHANGE_MAX_KEY_SIZE) + 1;
+ HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1;
break;
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-03-12 13:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-10 23:31 [PATCH 0000/0004] drivers: hv K. Y. Srinivasan
2012-03-10 23:32 ` [PATCH 1/4] Drivers: hv: Add new message types to enhance KVP K. Y. Srinivasan
2012-03-10 23:32 ` [PATCH 2/4] Drivers: hv: Support the newly introduced KVP messages in the driver K. Y. Srinivasan
2012-03-11 10:42 ` Dan Carpenter
2012-03-11 16:01 ` Alan Stern
2012-03-11 16:56 ` KY Srinivasan
2012-03-11 18:49 ` Dan Carpenter
2012-03-11 20:53 ` KY Srinivasan
2012-03-12 5:22 ` Dan Carpenter
2012-03-12 12:36 ` KY Srinivasan
2012-03-12 13:03 ` Dan Carpenter [this message]
2012-03-15 23:36 ` KY Srinivasan
2012-03-16 5:38 ` Dan Carpenter
2012-03-16 5:43 ` KY Srinivasan
2012-03-10 23:32 ` [PATCH 3/4] Tools: hv: Fully support the new KVP verbs in the user level daemon K. Y. Srinivasan
2012-03-10 23:32 ` [PATCH 4/4] Tools: hv: Support enumeration from all the pools K. Y. Srinivasan
2012-03-13 21:50 ` [PATCH 0000/0004] drivers: hv Greg KH
2012-03-15 23:26 ` KY Srinivasan
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=20120312130353.GF3337@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ohering@suse.com \
--cc=stern@rowland.harvard.edu \
--cc=virtualization@lists.osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox