ohadravid / wmi-rs

WMI crate for rust
Apache License 2.0
84 stars 27 forks source link

WMIConnection::create_services hangs indefinitely calling IWbemLocator::ConnectServer #56

Closed disassembledd closed 2 years ago

disassembledd commented 2 years ago

Hi,

I have identified an issue within WMIConnection::create_services where it is passing 0 for lSecurityFlags when calling IWbemLocator::ConnectServer. According to Microsoft docs, this causes the API to attempt to connect indefinitely, leading to moments where a simple query will halt the entire program.

I suggest the default for lSecurityFlags be changed to WBEM_FLAG_CONNECT_USE_MAX_WAIT and an unsafe option be given to wait indefinitely to prevent future cases such as this.

ohadravid commented 2 years ago

Sound good to me. I don't think there's a use case for the indefinite wait so we don't need to support it at all IMO (and it wouldn't be unsafe anyway as far as I can tell).

Do you want to open a PR with this change?

Thanks for taking the time to report this!

disassembledd commented 2 years ago

If you don't mind making the change yourself that'd be great. I mostly operate off of my work device unfortunately!