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

add additional check for valid time values #62

Merged
merged 1 commit into from Jul 21, 2017

Conversation

dirk-thomas
Copy link
Member

Replaces #60.

Adds additional checks around time source that the values are within the limits of the used data structures.

@ros/ros_team Please review.

@@ -108,11 +108,15 @@ namespace ros
#if HAS_CLOCK_GETTIME
timespec start;
clock_gettime(CLOCK_REALTIME, &start);
if (start.tv_sec < 0 || start.tv_sec > UINT_MAX)
Copy link
Member

Choose a reason for hiding this comment

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

Same as the other pr, might want to use UINT32_MAX:

http://en.cppreference.com/w/cpp/types/integer

Copy link
Member Author

Choose a reason for hiding this comment

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

For reference: #61 (comment)

int64_t start_sec64 = start_li.QuadPart / 10000000; // 100-ns units
if (start_sec64 < 0 || start_sec64 > UINT_MAX)
throw std::runtime_error("SystemTime is out of dual 32-bit range");
start_sec = (uint32_t)(start_sec64);
Copy link
Member

Choose a reason for hiding this comment

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

The second () seem redundant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed - and gone. Thanks.

@dirk-thomas dirk-thomas merged commit ece7013 into kinetic-devel Jul 21, 2017
@dirk-thomas dirk-thomas deleted the rostime_check_time_sources branch July 21, 2017 01:42
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.

None yet

2 participants