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

value overflow in serialize of log_entry #349

Open
tobecontinued opened this issue Apr 12, 2022 · 1 comment
Open

value overflow in serialize of log_entry #349

tobecontinued opened this issue Apr 12, 2022 · 1 comment

Comments

@tobecontinued
Copy link

tobecontinued commented Apr 12, 2022

hi @greensky00 , I found a potenal issue, could you pls have a look.

In log_val_type , custom is set to 999

enum log_val_type {
    app_log         = 1,
    conf            = 2,
    cluster_server  = 3,
    log_pack        = 4,
    snp_sync_req    = 5,
    custom          = 999,
};

But log_entry uses uint8 to store the value_type_ whose type is value_type_, but max of uint8 is 255.

    ptr<buffer> serialize() {
        buff_->pos(0);
        ptr<buffer> buf = buffer::alloc( sizeof(ulong) +
                                         sizeof(char) +
                                         buff_->size() );
        buf->put(term_);
        buf->put( (static_cast<byte>(value_type_)) );
        buf->put(*buff_);
        buf->pos(0);
        return buf;
    }
@greensky00
Copy link
Contributor

Thanks, let me think of the fix without hurting the backward compatibility.

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

2 participants