Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SETBIT/GETBIT overflowed while offset was equal or greater than 2147483648 #401

Closed
@legendhb

Description

@legendhb

Hi, when work with this extension, I found that SETBIT & GETBIT , the maximum value of the parameter 'offset' is 2147483647(system environment is x64), the method would return 'false' if offset was greater than this value.

As the Official of Redis said:'The offset argument is required to be greater than or equal to 0, and smaller than 232 (this limits bitmaps to 512MB).'

So, I downloaded the source code of phpredis, and found that line 1771 in 'redis.c'
cmd_len = redis_cmd_format_static(&cmd, "SETBIT", "sdd", key, key_len, (int)offset, (int)val);

the 'offset' was explicit converse to integer, and the 'format' was sent by 'sdd', but actually, the variable 'offset' was declared to 'long' lines before.

I commented the explicit conversion and change the 'format' into 'sld', the problem solved.

Could you please tell me, was this a bug? or something you did deliberately?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions