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

_sym_get_input_byte() in simple backend #136

Open
ercoppa opened this issue Mar 24, 2023 · 0 comments
Open

_sym_get_input_byte() in simple backend #136

ercoppa opened this issue Mar 24, 2023 · 0 comments

Comments

@ercoppa
Copy link
Contributor

ercoppa commented Mar 24, 2023

The current implementation of _sym_get_input_byte in the simple backend is:

Z3_ast _sym_get_input_byte(size_t offset, uint8_t) {
  static std::vector<SymExpr> stdinBytes;

  if (offset < stdinBytes.size())
    return stdinBytes[offset];

  auto varName = "stdin" + std::to_string(stdinBytes.size());
  auto *var = build_variable(varName.c_str(), 8);

  stdinBytes.resize(offset);
  stdinBytes.push_back(var);

  return var;
}

This does not work well in the case of lseek/fseek operations:

  1. suppose a *seek operation moves the offset to X > 0
  2. when asking for the input byte at offset X, the resize operation will create missing entries with NULL value for entries before X
  3. if another seek operation moves back the offset, then the check offset < stdinBytes.size() will then make return NULL for entries before X

Moreover, the varName should likely be "stdin" + std::to_string(offset) to be more intuitive.

Am I right?

Let me know if this could be a reasonable fix (or how to improve it).

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