-
Notifications
You must be signed in to change notification settings - Fork 194
function u2fh_register2 get wrong result because pointer error #89
Comments
In what way does this impact the u2fh_register2() function and what errors does it lead to? |
errorplease note the response in u2fh_register2().the response is same as p in my test code.if you use the u2fh_register2(),you may get wrong result in response,because function u2fh_register2() write to wrong address in test code result,you can see that if we use str2,it write result in 0x0060FF10 rather then 0x0060FF2C U2FH_EXPORT u2fh_rc u2fh_register (u2fh_devs * devs,
const char *challenge,
const char *origin,
char **response, u2fh_cmdflags flags);
U2FH_EXPORT u2fh_rc u2fh_register2 (u2fh_devs * devs,
const char *challenge,
const char *origin,
char *response, size_t * response_len,
u2fh_cmdflags flags);
u2fh_rc
u2fh_register2 (u2fh_devs * devs,
const char *challenge,
const char *origin, char *response, size_t * response_len,
u2fh_cmdflags flags)
{
return _u2fh_register (devs, challenge, origin, &response, response_len,
flags);
}
u2fh_rc
u2fh_register (u2fh_devs * devs,
const char *challenge,
const char *origin, char **response, u2fh_cmdflags flags)
{
size_t response_len = 0;
*response = NULL;
return _u2fh_register (devs, challenge, origin, response, &response_len,
flags);
} solutionyou can change u2fh_register2 response from char * to char **,and fix _u2fh_register U2FH_EXPORT u2fh_rc u2fh_register2 (u2fh_devs * devs,
const char *challenge,
const char *origin,
char **response, size_t * response_len,
u2fh_cmdflags flags);
u2fh_rc
u2fh_register2 (u2fh_devs * devs,
const char *challenge,
const char *origin, char **response, size_t * response_len,
u2fh_cmdflags flags)
{
return _u2fh_register (devs, challenge, origin, response, response_len,
flags); |
We never write to the response directly, only to the dereferenced version of it. |
In function u2fh_register2, the parameter sent to _u2fh_register is &response, which is different from that of u2f_register. That would cause a problem as I stated in the first example. |
We are archiving this project and closing issues. Please open a new one in the replacement library's repo: https://github.com/Yubico/libfido2 if it is still applicable. |
I use function u2fh_register2 to test my token,but I get puzzling results
So I write simple test code to reappear the puzzling results
You may have noticed that the &p in str2 is defferent to main &p
Please fix it.Thank you
Test Code
Result
mainp = 00BA13A8 main&p = 0060FF2C
str1_**p = 0060FF2C
test_p = 0060FF2C
str2_*p = 00BA13A8
str2_**p = 0060FF10
test_p = 0060FF10
The text was updated successfully, but these errors were encountered: