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

fix potential oob writes #435

Closed
wants to merge 2 commits into from
Closed

Conversation

jmartins-ledger
Copy link
Contributor

Description

If there is a ticker available check if we can write the ticker and the empty space.
If the ticker_len is larger than out_buffer_size then buffer is full, return failure

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Tests
  • Documentation
  • Other (for changes that might not fit in any category)

out_buffer[ticker_len++] = ' ';
}

if (out_buffer_size < ticker_len) {
Copy link
Contributor

@cedelavergne-ledger cedelavergne-ledger Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather put this check before the previous if statement.
Then , this could be simplified with only:

if (ticker_len > 0) {
    if (out_buffer_size <= ticker_len + 1) {
        return false;
    }
    memcpy(out_buffer, ticker, ticker_len);
    out_buffer[ticker_len++] = ' ';
}

@cedelavergne-ledger
Copy link
Contributor

Please rebase your branch also 😉

@cedelavergne-ledger cedelavergne-ledger mentioned this pull request Apr 12, 2024
6 tasks
@cedelavergne-ledger
Copy link
Contributor

Closing, because files have been moved/renamed.
This PR is now tracked here: #566

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

Successfully merging this pull request may close these issues.

2 participants