-
Notifications
You must be signed in to change notification settings - Fork 291
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
fix: Avoid memcpy
-ing structs into onion ping id data.
#2687
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2687 +/- ##
==========================================
+ Coverage 72.89% 73.14% +0.24%
==========================================
Files 149 149
Lines 30570 30565 -5
==========================================
+ Hits 22285 22357 +72
+ Misses 8285 8208 -77 ☔ View full report in Codecov by Sentry. |
68302cd
to
d974afe
Compare
d974afe
to
82545f5
Compare
82545f5
to
0f72a4c
Compare
Although it is only ever read back on the machine it originated from, it's bad practice and we should not make our protocol have system-specific undefined padding bytes in it.
memcpy(ping_id_data, packet_public_key, CRYPTO_PUBLIC_KEY_SIZE); | ||
memcpy(ping_id_data + CRYPTO_PUBLIC_KEY_SIZE, source, sizeof(*source)); | ||
const int packed_len = pack_ip_port(onion_a->log, &ping_id_data[CRYPTO_PUBLIC_KEY_SIZE], SIZE_IPPORT, source); | ||
memzero(&ping_id_data[CRYPTO_PUBLIC_KEY_SIZE + packed_len], SIZE_IPPORT - packed_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert packed_len <= SIZE_IPPORT ?
Although it is only ever read back on the machine it originated from, it's bad practice and we should not make our protocol have system-specific undefined padding bytes in it.
Found by TokTok/hs-tokstyle#252
This change is