Skip to content

Fix GH-9945: Reject shmop/sysvshm keys outside key_t range#22423

Merged
LamentXU123 merged 1 commit into
php:masterfrom
LamentXU123:fix-shmop-ValueError
Jun 24, 2026
Merged

Fix GH-9945: Reject shmop/sysvshm keys outside key_t range#22423
LamentXU123 merged 1 commit into
php:masterfrom
LamentXU123:fix-shmop-ValueError

Conversation

@LamentXU123

Copy link
Copy Markdown
Member

Now, shmop_open() and shm_attach() accepted zend_long keys and passed them directly to SysV shared memory APIs, where they may be truncated to key_t.

Generally we should throw ValurErrors on those issues. Fixes #9945

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ideally a better error message would be possible, but this is at least something :)

@LamentXU123

Copy link
Copy Markdown
Member Author

@Girgias Lets see if this message would be better :)

shm_attach(): Argument #1 ($key) must be representable as key_t

@Girgias

Girgias commented Jun 24, 2026

Copy link
Copy Markdown
Member

@Girgias Lets see if this message would be better :)

shm_attach(): Argument #1 ($key) must be representable as key_t

I don't think so, as end-users won't have any idea what that is. So keeping a generic message of out of range is probably better.

@LamentXU123

Copy link
Copy Markdown
Member Author

Fair :)

@LamentXU123 LamentXU123 force-pushed the fix-shmop-ValueError branch from 79494eb to 270ffa7 Compare June 24, 2026 10:42
@LamentXU123 LamentXU123 merged commit 34116ad into php:master Jun 24, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shmop_open should throw ValueError for ids overflowing sizeof int

2 participants