[SERVER-51287] Coverity analysis defect 114973: Argument cannot be negative Created: 01/Oct/20  Updated: 29/Oct/23  Resolved: 24/Nov/20

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: coverity, servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service arch 2020-11-30
Participants:

 Description   

Argument cannot be negative

The negative argument will be interpreted as a very large unsigned value. Negative value used as argument to a function expecting a positive value (for example, size of buffer or allocation)
/src/mongo/transport/transport_layer_asio.cpp:725: NEGATIVE_RETURNS 114973 Function "socket(2, SOCK_STREAM, 0)" returns a negative number.
/src/mongo/transport/transport_layer_asio.cpp:725: NEGATIVE_RETURNS 114973 Assigning: "sock" = "socket(2, SOCK_STREAM, 0)".
/src/mongo/transport/transport_layer_asio.cpp:733: NEGATIVE_RETURNS 114973 "sock" is passed to a parameter that cannot be negative.



 Comments   
Comment by Githook User [ 24/Nov/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-51287 check socket() call for failure
Branch: master
https://github.com/mongodb/mongo/commit/79be0f22b131489173d6d6aa068f0f90f97e338b

Comment by Billy Donahue [ 19/Nov/20 ]

CR https://mongodbcr.appspot.com/736010001/

Comment by Billy Donahue [ 19/Nov/20 ]

We didn't check the ::socket call for failure. Tsk.

Generated at Thu Feb 08 05:25:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.