Skip to content

Off-by-one error in GetAllPropertyValues results in missing properties #7

@jcaron23

Description

@jcaron23

When using wmi.query without the third argument, it is supposed to return all properties from the query.

I was stumped because wmi.query('root/StandardCimv2', 'SELECT * FROM MSFT_NetConnectionProfile') did not return the NetworkCategory property.

If I specify the list of properties, then NetworkCategory is correctly returned.

It looks like in https://github.com/intel/wmi-native-module/blob/main/src/wmi_wrapper.cpp in GetAllPropertyValues, start and end indices into the array are retrieved via SafeArrayGetLBound and SafeArrayGetUBound. There's then a for (int i = start; i < end; ++i) to iterate over them.

However SafeArrayGetUBound is the actual upper bound, i.e. the indices are inclusive.

It's probably enough to change the loop's condition to i <= end to fix the issue. I haven't had the opportunity to try it yet, if someone has the time to try it and (if I'm correct) fix it before I can, please do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions