mirror of
https://github.com/google/brotli.git
synced 2026-09-22 06:35:52 +00:00
Issues uncovered by Coverity Scan #17
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @nemequ on GitHub (Aug 28, 2015).
This is with revision
d811b186c5. I can't really reproduce the full report here, but here is a summary of each item it found.enc/histogram.h:37: Non-static class memberbit_cost_is not initialized in this constructor nor in any functions that it calls.enc/command.h:106: Non-static class membersinsert_len_,copy_len_,cmd_prefix_,dist_prefix_,cmd_extra_, anddist_extra_are not initialized in this constructor nor in any functions that it calls.enc/brotli_bit_stream.cc:343:indexis passed to a parameter that cannot be negative. IndexOf can return -1enc/literal_cost.cc:102: Execution cannot reach the expression 0 inside this statement:last_c = ((i + window_half …i + window_half - 2 < 0, the value ofimust be at least 0.i + window_half - 2 < 0, the value ofwindow_halfmust be equal to 495.i + window_half - 2 < 0cannot be true.enc/prefix.h:75: In expressiondistance_code >> bucket, shifting by a negative amount has undefined behavior. The shift amount,bucket, is -2.brotli::Log2Floor(distance_code)returns -1.bucket = brotli::Log2Floor(distance_code) - 1. The value ofbucketis now -2.enc/entropy_encode.cc:45: Non-static class memberstotal_count_,index_left_, andindex_right_or_value_are not initialized in this constructor nor in any functions that it calls.enc/backward_references.cc:157: The compiler-generated constructor for this class does not initializemin_cost_cmd_enc/encode.cc:207: Non-static class memberliteral_cost_mask_is not initialized in this constructor nor in any functions that it calls.dec/huffman.c:142: Using uninitialized valuesorted[symbol++]dec/decode.c:871: Using uninitialized values.loop_counterwhen callingBrotliDecompressStreamingenc/metablock.cc:496: Using tainted variable context as an index to pointerstatic_context_mapenc/static_dict.cc:391:data[0] == '\xc2'is always false regardless of the values of its operands. This occurs as the logical operand of if.If you need more details about an item let me know. I only provided the full information on the one item because it is a bit difficult to follow without the it, but I think the others should be pretty easy to figure out.
@nemequ commented on GitHub (Sep 6, 2015):
FWIW I would be willing to add someone to Squash's project on Coverity Scan so you can see the results in their interface, though I would suggest just creating a project for brotli. It has actually uncovered quite a few real issues in other compression libraries (as well as Squash itself) with surprisingly few false positives—definitely worth it, IMHO.
@eustas commented on GitHub (Oct 6, 2015):
All Coverity Scan reports have been addressed =)
See https://scan.coverity.com/projects/google-brotli
Thank you for reporting about these issues.
@nemequ commented on GitHub (Jul 12, 2016):
I think it's time for another run; Coverity is reporting 9 high-impact issues and 4 medium-impact issues in Brotli.
@eustas commented on GitHub (Jul 12, 2016):
Uninitialized variables and null-dereference are all false-positives. Usage of tainted values is natural -> almost false positive. Going to toss coda a little bit to convince Coverity Scan.
@nemequ commented on GitHub (Jul 12, 2016):
FWIW, cppcheck picks up a couple minor issues, too:
To fix the second one, you could cast to int, or if you want to really use size_t you can do something like this (stolen from https://github.com/nemequ/munit/blob/master/munit.h#L56):
Windows make everything harder.
@nemequ commented on GitHub (Jul 13, 2016):
@eustas, I see the only issue remaining is a null-pointer dereference; IIRC that can be "fixed" by adding an
assert(foo != NULL). If it's a function parameter, another possibility might be to add a nonnnull attribute… Looks like it's available in GCC 3.3+.