Thanks for catching this!

It slipped my mind when I wrote the code.

Mind adding a define for the number of element instead and passing that in?
i.e.
#define WMI_QUERY 2048
    wchar_t internal_port_query[WMI_QUERY] = L"SELECT * from "
        L"Msvm_EthernetPortAllocationSettingData  WHERE ElementName = \"" ; 
....
wcscat_s(internal_port_query, WMI_QUERY, wide_name);
instead?
(I am using for both delete/create and maybe we want to increase its size)

Also another thing that I forgot is to check the output of wcscat_s/wcscpy_s. 
In only managed to check it once in 'get_str_value' :(.

Should I send an incremental?

Thanks,
Alin.

> -----Original Message-----
> From: [email protected] [mailto:ovs-dev-
> [email protected]] On Behalf Of Sairam Venugopal
> Sent: Friday, January 27, 2017 7:58 AM
> To: [email protected]
> Subject: [ovs-dev] [PATCH] Windows: Fix wmi.c to use count of wchar_t
> instead of sizeof
> 
> wcscat_s and wcscpy_s requires number of elements as argument. wchar_t
> uses 2 bytes for storage and using sizeof(internal_port_query) causes access
> violation error on Windows 2012 R2 (64 bit). This patch introduces a
> count_of() function to return the count of the wchar_t array.
> 
> Signed-off-by: Sairam Venugopal <[email protected]>
> Reported-by: Sairam Venugopal <[email protected]>
> Reported-at: openvswitch/ovs-issues#121
> ---
>  lib/wmi.c | 34 +++++++++++++++++++---------------
>  1 file changed, 19 insertions(+), 15 deletions(-)
> 
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to