Skip to content

these are not available in 32bit pack: q, Q, J, P #4644

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

divinity76
Copy link
Contributor

@divinity76 divinity76 commented Apr 30, 2025

see https://github.com/php/php-src/blob/156d034d3da314925a77115538b55c7097c662cc/ext/standard/pack.c#L320-L330
line 320-330.

(but I don't wanna say "64bit formats are not available in 32bit" because d, e, E, the float64 formats are available in 32bit builds, contrary to what the php-src error message suggest.)

divinity76 added a commit to divinity76/wrench that referenced this pull request May 1, 2025
off-by-1: previously, hybiframes with a 65536 bytes payload
would generate a 16 bit size header signaling 0 bytes (pack("n", 65536) => "\x00\x00"),
instead of using a 64bit size header.

nit: composer.json php version had not been updated since 8.0.2

nit: instead of is_int && in_array, we can use in_array's strict mode.

nit: $this->offset_mask and $this->offset_payload were
initialized-to-null in constructor and encode, then written internally in getPayloadOffset,
 then written in encode() again.

nit: use pack('J') instead of manually constructing big_endian_u64 (undocumented funfact, J is not available in 32bit php: php/doc-en#4644 ,
that may be why the original code did not use J)

nit: use random_bytes instead of openssl_random_pseudo_bytes(),
the original code was written for php5 where random_bytes did not exist.

nit: getInitialLength() was calculating the result twice internally.
GrahamCampbell pushed a commit to chrome-php/wrench that referenced this pull request May 1, 2025
* fix size 65536 HybiFrame + nitpicks

off-by-1: previously, hybiframes with a 65536 bytes payload
would generate a 16 bit size header signaling 0 bytes (pack("n", 65536) => "\x00\x00"),
instead of using a 64bit size header.

nit: composer.json php version had not been updated since 8.0.2

nit: instead of is_int && in_array, we can use in_array's strict mode.

nit: $this->offset_mask and $this->offset_payload were
initialized-to-null in constructor and encode, then written internally in getPayloadOffset,
 then written in encode() again.

nit: use pack('J') instead of manually constructing big_endian_u64 (undocumented funfact, J is not available in 32bit php: php/doc-en#4644 ,
that may be why the original code did not use J)

nit: use random_bytes instead of openssl_random_pseudo_bytes(),
the original code was written for php5 where random_bytes did not exist.

nit: getInitialLength() was calculating the result twice internally.

* StyleCI

* PR feedback

https://github.com/chrome-php/wrench/pull/24/files#r2070000317
and
https://github.com/chrome-php/wrench/pull/24/files#r2069999223
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.

1 participant