Fix unsigned integer overflow in LoadMempool #24227

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2202-intMem changing 1 files +2 −1
  1. MarcoFalke commented at 2:51 PM on February 1, 2022: member

    It doesn't seem ideal to have an integer sanitizer enabled, but then disable it for the whole validation.cpp file.

    This removes one of the two violations.

    This should be a refactor.

  2. MarcoFalke added the label Refactoring on Feb 1, 2022
  3. MarcoFalke added the label Validation on Feb 1, 2022
  4. MarcoFalke force-pushed on Feb 1, 2022
  5. MarcoFalke cross-referenced this on Feb 1, 2022 from issue Fix integer sanitizer suppressions in validation.cpp by MarcoFalke
  6. PastaPastaPasta approved
  7. PastaPastaPasta commented at 4:16 PM on February 1, 2022: contributor

    utACK aaaae5349d1d5985081751c3a3b7386333d48cef, I reviewed the code, and agree it makes sense to merge

  8. Fix unsigned integer overflow in LoadMempool fadcd03139
  9. MarcoFalke force-pushed on Feb 1, 2022
  10. MarcoFalke commented at 7:01 PM on February 1, 2022: member

    I've pushed a new version, which:

    • is a smaller diff and easier to review, as it doesn't change any types
    • doesn't introduce a presumed signed-integer-overflow when the mempool.dat on disk is badly corrupted
  11. luke-jr approved
  12. luke-jr commented at 9:33 PM on February 5, 2022: member

    utACK

  13. unknown approved
  14. unknown commented at 1:42 AM on February 6, 2022: none

    Code Review ACK https://github.com/bitcoin/bitcoin/pull/24227/commits/fadcd031390dd4588bbb1c07e5020a7131312050

    Tried running below code to confirm:

      uint64_t i = 4;
      while (--i)
      { 
      cout<<i;
      }
      cout<<i;
      
    
      uint64_t i = 4;
      while (i--)
      { 
      cout<<i;
      }
      cout<<i;
      
    
      uint64_t i = 4;
      while (i)
      { 
       --i;
      cout<<i;
      }
      cout<<i;
      
    

    It is also according to coding style mentioned in docs: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-c

  15. PastaPastaPasta commented at 9:22 AM on February 7, 2022: contributor

    Is the PR name really accurate, this can't overflow, maybe only underflow?

  16. MarcoFalke commented at 9:50 AM on February 7, 2022: member

    No idea, but the suppression is called unsigned-integer-overflow, which is why I picked the title.

  17. PastaPastaPasta commented at 10:23 AM on February 7, 2022: contributor

    No idea, but the suppression is called unsigned-integer-overflow, which is why I picked the title.

    I presume there are more unsigned-integer-overflow in validation.cpp preventing you from removing the suppression?

  18. MarcoFalke commented at 10:35 AM on February 7, 2022: member

    Have you seen the pull request you commented on? #24196#pullrequestreview-868681878

  19. PastaPastaPasta commented at 11:58 AM on February 7, 2022: contributor

    Have you seen the pull request you commented on? #24196 (review)

    Ahh, thanks, I forgot they were related / about that PR

  20. MarcoFalke merged this on Feb 7, 2022
  21. MarcoFalke closed this on Feb 7, 2022

  22. MarcoFalke deleted the branch on Feb 7, 2022
  23. sidhujag referenced this in commit eac3f64704 on Feb 7, 2022
  24. PastaPastaPasta referenced this in commit cbc14612ba on Apr 7, 2022
  25. PastaPastaPasta referenced this in commit ef93418b9a on Apr 11, 2022
  26. gades referenced this in commit 707272a142 on Apr 19, 2022
  27. Fabcien referenced this in commit 293b7411ec on Dec 19, 2022
  28. bitcoin locked this on Feb 7, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:53 UTC