Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndn_sig_verifier_verify_data is not reentrant #68

Open
yoursunny opened this issue Feb 11, 2020 · 0 comments
Open

ndn_sig_verifier_verify_data is not reentrant #68

yoursunny opened this issue Feb 11, 2020 · 0 comments

Comments

@yoursunny
Copy link
Contributor

The function writes into a global variable m_userdata. Consequently, if the application invokes ndn_sig_verifier_verify_data with a new Data packet before the previous validation has completed, undefined behavior may occur.

static ndn_sig_verifier_userdata_t m_userdata;
static ndn_sig_verifier_state_t m_sig_verifier_state;
static uint8_t verifier_buf[4096];

m_userdata.is_interest = false;
m_userdata.original_pkt = (void*)&data;
m_userdata.on_success_cbk = on_success;
m_userdata.on_failure_cbk = on_failure;

To solve this issue:

  1. Introduce a ndn_sig_verifier_verify_data_r function that accepts a context argument to carry per-validation state, to be used in place of the global variable(s). The calling application is responsible for allocating memory (either statically or dynamically) for the context struct.
  2. Implement ndn_sig_verifier_verify_data as a wrapper of ndn_sig_verifier_verify_data that uses global variable or function-scope static variable as context.
  3. Update the documentation of ndn_sig_verifier_verify_data to note the non-reentrancy limitation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant