Make sure we're not using an uninitialized variable in secp256k1_wnaf_const(...) #533

pull practicalswift wants to merge 1 commits into bitcoin-core:master from practicalswift:uninitialized-u changing 1 files +6 −2
  1. practicalswift commented at 7:44 AM on May 6, 2018: contributor

    Make sure we're not using an uninitialized variable in secp256k1_wnaf_const(...):

    In file included from src/secp256k1.c:15:0,
                     from src/tests.c:17:
    src/ecmult_const_impl.h: In function ‘secp256k1_wnaf_const’:
    src/ecmult_const_impl.h:117:20: warning: ‘u’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         wnaf[word] = u * global_sign;
                        ^
    

    Note to reviewers: Perhaps an assert(…); is a bit drastic. What would be a more graceful way to handle this? :-)

  2. sipa commented at 8:27 PM on May 7, 2018: contributor

    We don't use assert in the secp256k1 codebase. Instead I suggest you:

    • Turn the while loop into a do loop.
    • Add a VERIFY_CHECK(size > 0); (which only affects the code in unit tests).
  3. practicalswift force-pushed on May 7, 2018
  4. practicalswift force-pushed on May 7, 2018
  5. practicalswift commented at 8:52 PM on May 7, 2018: contributor

    @sipa Makes perfect sense. Thanks for the quick feedback!

    I've now pushed an updated version. Please re-review :-)

  6. Empact commented at 9:40 AM on June 6, 2018: contributor

    utACK 5f10203

  7. gmaxwell commented at 4:59 PM on July 11, 2018: contributor

    ACK

  8. ghost commented at 4:03 PM on July 16, 2018: none

    ; ) 確認

  9. jonasnick commented at 10:01 AM on October 29, 2018: contributor

    utACK

  10. gmaxwell commented at 4:42 AM on February 21, 2019: contributor

    On re-review, I believe we need to VERIFY_CHECK w>0 for the loop transformation to be correct. (obviously w>0 or the code is already broken... so.) @sipa opinion?

  11. real-or-random commented at 4:18 PM on February 22, 2019: contributor

    I think it's best to just VERIFY_CHECK(w > 0) too. If w == 0, we even divide by 0 in the VERIFY_CHECK here: https://github.com/bitcoin-core/secp256k1/blob/5f10203cfe3c40e7295aced2f36e090bb3f50e33/src/ecmult_const_impl.h#L119

  12. real-or-random commented at 4:39 PM on March 21, 2019: contributor

    @practicalswift: Could you update this?

  13. practicalswift commented at 5:25 PM on March 21, 2019: contributor

    @real-or-random Sure!

    Just to clarify (better safe than sorry!):

    Is the suggestion to change from:

    VERIFY_CHECK(size > 0);
    

    To:

    VERIFY_CHECK(w > 0);
    VERIFY_CHECK(size > 0);
    

    And otherwise leave the PR unchanged?

  14. real-or-random commented at 5:36 PM on March 21, 2019: contributor

    Yes that's my suggestion. :)

  15. Make sure we're not using an uninitialized variable in secp256k1_wnaf_const(...) 248f046611
  16. practicalswift force-pushed on Mar 21, 2019
  17. practicalswift commented at 6:07 PM on March 21, 2019: contributor

    @real-or-random Updated. Please re-review :-)

  18. real-or-random commented at 9:14 PM on March 21, 2019: contributor

    utACK 248f0466112c96b9851c662fa829f20d28d16344

  19. real-or-random cross-referenced this on Apr 1, 2019 from issue Changes necessary for usage on Trezor by real-or-random
  20. gmaxwell commented at 4:44 AM on May 22, 2019: contributor

    ACK

  21. gmaxwell merged this on May 22, 2019
  22. gmaxwell closed this on May 22, 2019

  23. gmaxwell referenced this in commit 5df77a0eda on May 22, 2019
  24. sipa cross-referenced this on Jun 9, 2020 from issue Update libsecp256k1 subtree by sipa
  25. fanquake referenced this in commit 8c97780db8 on Jun 13, 2020
  26. sidhujag referenced this in commit 8a3a072968 on Jun 13, 2020
  27. ComputerCraftr referenced this in commit b98f1c6e6c on Jun 16, 2020
  28. UdjinM6 referenced this in commit 9d36ba6570 on Aug 10, 2021
  29. 5tefan referenced this in commit 8ded2caa74 on Aug 12, 2021
  30. gades referenced this in commit d855cc511d on May 8, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-18 19:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me