[ovs-dev] [PATCH 10/10] datapath-windows: Add port friendly name to OVS_VPORT_ENTRY
Nithin Raju
nithin at vmware.com
Thu Oct 9 06:09:31 UTC 2014
> +/* OvsFindVportByHvName: "name" is assumed to be null-terminated */
> +POVS_VPORT_ENTRY
> +OvsFindVportByHvName(POVS_SWITCH_CONTEXT switchContext,
> + PSTR name)
> +{
> + POVS_VPORT_ENTRY vport = NULL;
> + PLIST_ENTRY head, link;
> + SIZE_T length = sizeof(name);
> + SIZE_T wstrSize = length * sizeof(WORD);
sizeof(name) does not yield the correct value on a PSTR which is the same as PCHAR.
I had to make the following fix to get this to work:
diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c
index bf19af8..5d72500 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -506,8 +506,8 @@ OvsFindVportByHvName(POVS_SWITCH_CONTEXT switchContext,
{
POVS_VPORT_ENTRY vport = NULL;
PLIST_ENTRY head, link;
- SIZE_T length = sizeof(name);
- SIZE_T wstrSize = length * sizeof(WORD);
+ SIZE_T length = strlen(name); /* 'portFriendlyName' is not NUL-terminated. */
+ SIZE_T wstrSize = length * sizeof(WCHAR);
> +
> + PWSTR wsName = OvsAllocateMemory(wstrSize);
> + if (!wsName) {
> + vport = NULL;
> + goto Cleanup;
If we jump to 'Cleanup', and call OvsFreeMemory(wsName) while wsName == NULL, we'll hit an ASSERT in OvsFreeMemory() that checks for a valid pointer.
thanks,
-- Nithin
More information about the dev
mailing list