| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Coverity is reporting issues with negative returns. I think that is because size_t page = GetPageSize(); will always result in page being positive even if GetPageSize fails and returns -1 since size_t cannot be negative. This then would result n the check right afterwards not catching the failure. Fix by converting to size_t after we do the check. Signed-off-by: Michael Dawson <mdawson@devrus.com>
|
Reports from coverity *** CID 278353: Error handling issues (NEGATIVE_RETURNS) /test/cctest/test_crypto_clienthello.cc: 57 in OverrunGuardedBuffer<(unsigned long)5>::OverrunGuardedBuffer()() 51 size_t page = GetPageSize(); 52 EXPECT_GE(page, N); 53 #endif 54 #ifdef USE_MPROTECT 55 // Place the packet right before a guard page, which, when accessed, causes 56 // a segmentation fault. >>> CID 278353: Error handling issues (NEGATIVE_RETURNS) >>> "page" is passed to a parameter that cannot be negative. 57 alloc_base = static_cast<uint8_t*>(aligned_alloc(page, 2 * page)); 58 EXPECT_NE(alloc_base, nullptr); 59 uint8_t* second_page = alloc_base + page; 60 EXPECT_EQ(mprotect(second_page, page, PROT_NONE), 0); 61 data_base = second_page - N; 62 #elif defined(USE_VIRTUALPROTECT) |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
I might be missing something but I don't see how this helps. GoogleTest's EXPECT_GE does not stop execution, it just logs an error. (I didn't know this at first, which is why I used EXPECT_GE in GetPageSize(), see #44795.)
Sorry, something went wrong.
That's kind of exactly what GetPageSize() does internally: assign to an int first, check that it is positive, then cast to size_t :) |
Sorry, something went wrong.
|
@tniessen I can't remember what I was thinking at this point, but I see your point so closing. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Coverity is reporting issues with negative
returns. I think that is because
size_t page = GetPageSize();
will always result in page being positive even if GetPageSize fails and returns -1 since size_t cannot be negative. This then would result n the check right afterwards not catching the failure.
Fix by converting to size_t after we do the check.
Signed-off-by: Michael Dawson mdawson@devrus.com