Skip to content
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

cleanup: Use memzero(x, s) instead of memset(x, 0, s). #2594

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Jan 24, 2024

It's clearer and doesn't risk having a non-zero filler value.


This change is Reviewable

@iphydf iphydf added this to the v0.2.19 milestone Jan 24, 2024
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (a7258e4) 73.60% compared to head (7dba23d) 73.60%.

❗ Current head 7dba23d differs from pull request most recent head 8f07755. Consider uploading reports for the commit 8f07755 to get more accurate results

Files Patch % Lines
toxcore/group_chats.c 66.66% 2 Missing ⚠️
toxcore/crypto_core.c 88.88% 1 Missing ⚠️
toxcore/friend_connection.c 0.00% 1 Missing ⚠️
toxcore/network.c 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2594   +/-   ##
=======================================
  Coverage   73.60%   73.60%           
=======================================
  Files         148      148           
  Lines       30342    30339    -3     
=======================================
- Hits        22333    22332    -1     
+ Misses       8009     8007    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iphydf iphydf force-pushed the memzero branch 5 times, most recently from 68bec1e to 709fd3b Compare January 24, 2024 15:50
Copy link
Member

@JFreegman JFreegman left a comment

Choose a reason for hiding this comment

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

Reviewed 16 of 17 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @iphydf)


toxcore/net_crypto.c line 1142 at r2 (raw file):

    memcpy(packet, &buffer_start, sizeof(uint32_t));
    memcpy(packet + sizeof(uint32_t), &num, sizeof(uint32_t));
    memzero(packet + (sizeof(uint32_t) * 2), padding_length);

I'm not sure about this one. The packet padding bytes needs to match PACKET_ID_PADDING, which we're now just assuming is 0. We should either remove the define or adhere to it.


toxcore/util.h line 52 at r2 (raw file):

/**
 * @brief Set all bytes in `data` to 0.

Maybe mention that this doesn't do a secure wipe, and a different function should be used for sensitive data.

Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @JFreegman)


toxcore/net_crypto.c line 1142 at r2 (raw file):

Previously, JFreegman wrote…

I'm not sure about this one. The packet padding bytes needs to match PACKET_ID_PADDING, which we're now just assuming is 0. We should either remove the define or adhere to it.

I agree. #2593 should be done first. I factored that out of this PR into a separate PR.


toxcore/util.h line 52 at r2 (raw file):

Previously, JFreegman wrote…

Maybe mention that this doesn't do a secure wipe, and a different function should be used for sensitive data.

Good point. Added.

Copy link
Member

@JFreegman JFreegman left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained

@iphydf iphydf force-pushed the memzero branch 2 times, most recently from 611772e to 04ee577 Compare January 24, 2024 19:12
It's clearer and doesn't risk having a non-zero filler value.
@toktok-releaser toktok-releaser merged commit 8f07755 into TokTok:master Jan 24, 2024
54 checks passed
@iphydf iphydf deleted the memzero branch January 24, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants