Skip to content

select: make Curl_socket_check take timediff_t timeout#5240

Closed
bagder wants to merge 2 commits intomasterfrom
bagder/gopher-timecheck
Closed

select: make Curl_socket_check take timediff_t timeout#5240
bagder wants to merge 2 commits intomasterfrom
bagder/gopher-timecheck

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Apr 15, 2020

Coverity found CID 1461718:

Integer handling issues (CONSTANT_EXPRESSION_RESULT) "timeout_ms >
9223372036854775807L" is always false regardless of the values of its
operands. This occurs as the logical second operand of "||".

@mback2k
Copy link
Copy Markdown
Member

mback2k commented Apr 15, 2020

The same condition check would need to be applied to socks.c and schannel.c.

And I am preparing a PR to make the functions in select.c take timediff_t instead of time_t and handle the conversion internally. What do you think about this?

@bagder
Copy link
Copy Markdown
Member Author

bagder commented Apr 15, 2020

Sounds like a good move! I'll pause this PR then and we can close it again once your work lands.

@mback2k mback2k self-assigned this Apr 15, 2020
@bagder
Copy link
Copy Markdown
Member Author

bagder commented Apr 15, 2020

Then I will also hold off a fix for two if(timeout_ms < 0) checks in select.c where timeout_ms is a time_t. Those are bugs because we allow time_t to be unsigned on platforms...

@jay
Copy link
Copy Markdown
Member

jay commented Apr 15, 2020

I think we should ignore the analyzer in this case. Any compiler can optimize it away as is.

@bagder
Copy link
Copy Markdown
Member Author

bagder commented Apr 15, 2020

I agree that it is a totally harmless detail, but I think this code also risk causing compiler warnings so I still think we should take care of it.

mback2k added a commit to mback2k/curl that referenced this pull request Apr 20, 2020
Make all functions in select.[ch] take timeout_ms as timediff_t
which should always be large enough and signed on all platforms
to take all possible timeout values and avoid type conversions.

Related to curl#5240 and curl#5262
Replaces curl#5107
mback2k added a commit to mback2k/curl that referenced this pull request Apr 20, 2020
Now that all functions in select.[ch] take timediff_t instead
of the limited time_t or int, we can remove type conversions
and related preprocessor checks to silence compiler warnings.

Related to curl#5262
Supersedes curl#5214, curl#5220 and curl#5221
Closes curl#5240
Coverity found CID 1461718:

Integer handling issues (CONSTANT_EXPRESSION_RESULT) "timeout_ms >
9223372036854775807L" is always false regardless of the values of its
operands. This occurs as the logical second operand of "||".
@bagder bagder changed the title gopher: condition the timeout check to satisfy code analyzer select: make Curl_socket_check take timediff_t timeout Apr 23, 2020
@bagder bagder force-pushed the bagder/gopher-timecheck branch from 3186b4c to a78bb56 Compare April 23, 2020 08:09
@bagder
Copy link
Copy Markdown
Member Author

bagder commented Apr 23, 2020

I just want to add that this is meant to primarily address the problem Coverity detected before the pending release, it is not a replacement of #5262.

@bagder bagder closed this in a96c752 Apr 23, 2020
@bagder bagder deleted the bagder/gopher-timecheck branch April 23, 2020 14:03
jay added a commit to jay/curl that referenced this pull request Apr 23, 2020
Follow-up to a96c752 which changed the timeout_ms type from time_t to
timediff_t.

Ref: curl#5240

Closes #xxxx
jay added a commit that referenced this pull request May 2, 2020
Follow-up to a96c752 which changed the timeout_ms type from time_t to
timediff_t.

Ref: #5240

Closes #5286
mback2k added a commit to mback2k/curl that referenced this pull request May 26, 2020
Make all functions in select.[ch] take timeout_ms as timediff_t
which should always be large enough and signed on all platforms
to take all possible timeout values and avoid type conversions.

Replaces curl#5107 and partially curl#5262
Related to curl#5240 and curl#5286
Closes curl#5343
mback2k added a commit that referenced this pull request May 30, 2020
Make all functions in select.[ch] take timeout_ms as timediff_t
which should always be large enough and signed on all platforms
to take all possible timeout values and avoid type conversions.

Reviewed-by: Jay Satiro
Reviewed-by: Daniel Stenberg

Replaces #5107 and partially #5262
Related to #5240 and #5286
Closes #5343
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