[3.0] Demotes smf_crc32() to a backward compatibility function#9123
Merged
jdarwood007 merged 3 commits intoSimpleMachines:release-3.0from Feb 28, 2026
Merged
[3.0] Demotes smf_crc32() to a backward compatibility function#9123jdarwood007 merged 3 commits intoSimpleMachines:release-3.0from
jdarwood007 merged 3 commits intoSimpleMachines:release-3.0from
Conversation
de84ef5 to
4f1f73c
Compare
Although the integer value returned by crc32() can be different on 32-bit vs. 64-bit systems, `pack('N', crc32($tmp)` will always result in the same value on both 32-bit and 64-bit systems. This is because pack() only cares about the raw binary value, not the integer interpretation. Thus, there is no need to call smf_crc32() here; we can just use normal crc32() on both 32-bit and 64-bit systems.
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
4f1f73c to
7a382b1
Compare
jdarwood007
reviewed
Feb 28, 2026
| $out .= "\x00\x00\x00\x0D"; | ||
| $tmp = 'IHDR' . pack('N', (int) $this->header->m_nWidth) . pack('N', (int) $this->header->m_nHeight) . "\x08\x03\x00\x00\x00"; | ||
| $out .= $tmp . pack('N', smf_crc32($tmp)); | ||
| $out .= $tmp . pack('N', crc32($tmp)); |
Member
There was a problem hiding this comment.
Are there any worries about switching to just crc32 for our image handling?
Member
Author
There was a problem hiding this comment.
Nope. As shown in the testing instructions I gave above, pack('N', crc32($tmp)) and pack('N', smf_crc32($tmp)) produce identical results.
This is because the 'N' format treats the value as a 32-bit unsigned long, which means that it truncates all the extra bits that smf_crc32() prepends on 64-bit systems, leaving only the original 32-bit checksum returned by plain crc32(). This in turn means that calling smf_crc32() here is and has always been pointless.
live627
added a commit
to live627/SMF2.1
that referenced
this pull request
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pack('N', crc32($tmp)will always result in the same value on both 32-bit and 64-bit systems. This is because pack() only cares about the raw binary value, not the integer interpretation. Thus, there is no need to call smf_crc32() here; we can just use normal crc32() on both 32-bit and 64-bit systems.pack('N', smf_crc32($tmp))andpack('N', crc32($tmp))always produce the same results on both 32-bit and 64-bit platforms by going to https://3v4l.org/#live and running the following script:eval();button, it will execute again using a 64-bit build of PHP.