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

CxPlatTimespecToUs:Microsecond time conversion overflow on 32-bit unix platforms #4529

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

noah-hwang
Copy link
Contributor

CxPlatTimespecToUs:Microsecond time conversion overflow on 32-bit unix platforms

Description

Describe the purpose of and changes within this Pull Request.
The timespec structure is defined as follows
struct timespec
{
time_t tv_sec; // Seconds - >= 0
long tv_nsec; // Nanoseconds - [0, 999999999]
};
On a 32-bit platform, time_t t is usually defined as a 32-bit signed integer (int or long) .
Therefore, byte overflow occurs in the following calculation:
#define CXPLAT_MICROSEC_PER_SEC (1000000)
Time->tv_sec * CXPLAT_MICROSEC_PER_SEC
This will cause the calculated microsecond time to be discontinuous, and the time obtained after overflow is smaller than the last time obtained

Testing

Do any existing tests cover this change? Are new tests needed?

Documentation

Is there any documentation impact for this change?

@noah-hwang noah-hwang requested a review from a team as a code owner September 4, 2024 03:32
@nibanks nibanks added OS: Ubuntu external Proposed by non-MSFT Bug: Platform A code bug in platform/TLS specific code. labels Sep 4, 2024
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.71%. Comparing base (d5c2ac5) to head (fb8d109).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4529      +/-   ##
==========================================
- Coverage   86.25%   85.71%   -0.54%     
==========================================
  Files          56       56              
  Lines       15520    15520              
==========================================
- Hits        13386    13303      -83     
- Misses       2134     2217      +83     

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

@nibanks nibanks merged commit 80fceb0 into microsoft:main Sep 4, 2024
456 of 471 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Platform A code bug in platform/TLS specific code. external Proposed by non-MSFT OS: Ubuntu
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants