#291 config_nameserver_from_reg_key incorrect API usage

open
nobody
5
2012-10-23
2012-10-23
ross
No

In config_nameserver_from_reg_key we have:

if (RegQueryValueEx(key, subkey, 0, &type, NULL, &bufsz)
!= ERROR_MORE_DATA)
return -1;

From MSDN (http://msdn.microsoft.com/en-us/library/windows/desktop/ms724911(v=vs.85).aspx):

If lpData is NULL, and lpcbData is non-NULL, the function returns ERROR_SUCCESS and stores the size of the data, in bytes, in the variable pointed to by lpcbData. This enables an application to determine the best way to allocate a buffer for the value's data.

I think it should be checking for ERROR_SUCCESS or at least for either value.

Discussion

  • Nick Mathewson
    Nick Mathewson
    2012-10-23

    Sounds plausible; is this something you could write up a patch for?