>
>
>>-----Mesaj original-----
>De la: Nithin Raju [mailto:[email protected]] 
>Trimis: Thursday, October 9, 2014 9:10 AM
>Către: Alin Serdean
>Cc: [email protected]; Samuel Ghinet
>Subiect: Re: [ovs-dev] [PATCH 10/10] datapath-windows: Add port friendly name 
>to OVS_VPORT_ENTRY
>
>> +/* 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:
You are right Nithin.
>
>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.
>
Well I wanted to ASSERT there but I can just return NULL if you think is better.
>
>thanks,
>-- Nithin
>
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to