Skip to content

Deprecate load16_be() function in favor to ntohs() function.#2953

Open
starter48 wants to merge 6 commits into
shadowsocks:masterfrom
starter48:master
Open

Deprecate load16_be() function in favor to ntohs() function.#2953
starter48 wants to merge 6 commits into
shadowsocks:masterfrom
starter48:master

Conversation

@starter48

Copy link
Copy Markdown

load16_be() function is inefficient and basically does the same work as ntohs().

@madeye

madeye commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Thanks! One thing blocks merging as-is: replacing load16_be() (byte-wise, alignment-safe) with ntohs(*(uint16_t*)ptr) introduces an unaligned 16-bit load from a char* buffer — undefined behavior that can fault or misread on stricter-alignment targets (e.g. some ARM). Also in src/server.c the change drops ntohs() entirely (port = *(uint16_t*)(...)), flipping byte order on little-endian hosts. Could you keep an alignment-safe accessor (e.g. memcpy into a uint16_t then ntohs)? Happy to merge once that's addressed.

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.

2 participants