Skip to content

Fix #522 Signed integer overflow #526

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

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion php_memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int php_memc_list_entry(void) {
/****************************************
Payload value flags
****************************************/
#define MEMC_CREATE_MASK(start, n_bits) (((1 << n_bits) - 1) << start)
#define MEMC_CREATE_MASK(start, n_bits) (((1U << n_bits) - 1) << start)
Copy link
Contributor

Choose a reason for hiding this comment

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

I did a bit of reading, found a note that Coverity might interpret 1U as u_char rather than int: https://community.synopsys.com/s/article/False-positive-for-coverity-sees-1-and-1U-as-8-bit-type-variables

The fix would be to use 1UL to make it explicitly 32-bit (unsigned long)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but 1UL is 64-bit

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, there's a part of my brain that I keep on a shelf for this


#define MEMC_MASK_TYPE MEMC_CREATE_MASK(0, 4)
#define MEMC_MASK_INTERNAL MEMC_CREATE_MASK(4, 12)
Expand Down