Avoids a potentially shortening size_t to int cast in strauss_wnaf_ #841

pull real-or-random wants to merge 1 commits into bitcoin-core:master from real-or-random:202010_strauss_wnaf_counters changing 1 files +3 −3
  1. real-or-random commented at 1:57 pm on October 26, 2020: contributor
    Fixes #834.
  2. sipa cross-referenced this on Oct 26, 2020 from issue gcc emits -Warray-bounds warnings by hebasto
  3. sipa commented at 7:47 pm on October 26, 2020: contributor

    I confirm this fixes the

     0In file included from src/secp256k1.c:16:
     1src/ecmult_impl.h: In function secp256k1_ecmult.constprop:
     2src/ecmult_impl.h:496:48: warning: array subscript [1, 268435456] is outside array bounds of struct secp256k1_strauss_point_state[1] [-Warray-bounds]
     3  496 |             secp256k1_gej tmp = a[state->ps[np].input_pos];
     4      |                                   ~~~~~~~~~~~~~^~~~~~~~~~
     5src/ecmult_impl.h:565:42: note: while referencing ps
     6  565 |     struct secp256k1_strauss_point_state ps[1];
     7      |                                          ^~
     8src/ecmult_impl.h:502:139: warning: array subscript [1, 268435456] is outside array bounds of struct secp256k1_strauss_point_state[1] [-Warray-bounds]
     9  502 |             secp256k1_fe_mul(state->zr + np * ECMULT_TABLE_SIZE(WINDOW_A), state->zr + np * ECMULT_TABLE_SIZE(WINDOW_A), &(a[state->ps[np].input_pos].z));
    10      |                                                                                                                              ~~~~~~~~~~~~~^~~~~~~~~~
    11src/ecmult_impl.h:565:42: note: while referencing ps
    12  565 |     struct secp256k1_strauss_point_state ps[1];
    

    warning.

  4. hebasto commented at 8:21 pm on October 26, 2020: member

    Tested f1c9131c798107efa4b2e660ae37b183ac662741 on Linux Mint 20 (x86_64):

    0$ gcc --version
    1gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
    2Copyright (C) 2019 Free Software Foundation, Inc.
    3This is free software; see the source for copying conditions.  There is NO
    4warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    5
    6$ make > /dev/null
    7# no warnings :)
    
  5. gmaxwell commented at 11:56 pm on October 26, 2020: contributor
    This looks reasonable to me.
  6. Avoids a potentially shortening size_t to int cast in strauss_wnaf_
    Fixes #834.
    8893f42438
  7. real-or-random force-pushed on Oct 27, 2020
  8. real-or-random marked this as ready for review on Oct 27, 2020
  9. real-or-random commented at 1:19 am on October 27, 2020: contributor
    Ok, I didn’t expect that this will also fix the warning! Updated the commit message accordingly.
  10. sipa commented at 1:24 am on October 27, 2020: contributor

    Ok, I didn’t expect that this will also fix the warning! Updated the commit message accordingly.

    Bogus compiler warning acts bogusly.

  11. sipa commented at 1:27 am on October 27, 2020: contributor
    ACK 8893f42438ac75838a9dc7df7e98b29e9a1a085f. np and no shouldn’t ever take on negative values.
  12. jonasnick commented at 9:20 am on October 27, 2020: contributor

    ACK 8893f42438ac75838a9dc7df7e98b29e9a1a085f

    Also kicked travis since it hadn’t started the job.

  13. elichai commented at 10:06 am on October 27, 2020: contributor
    ACK 8893f42438ac75838a9dc7df7e98b29e9a1a085f Cool that it fixed the warning hehe
  14. jonasnick merged this on Oct 27, 2020
  15. jonasnick closed this on Oct 27, 2020

  16. hebasto commented at 1:29 pm on October 27, 2020: member
    Is it planned to pull this change into the Bitcoin Core repo before 0.21.0 branching off?
  17. gmaxwell commented at 4:54 pm on October 27, 2020: contributor
    @hebasto You’re asking in the wrong place, other than sipa no one else here regularly contributes to bitcoin-core. :)
  18. jasonbcox referenced this in commit 8f1b1aaef1 on Oct 27, 2020
  19. deadalnix referenced this in commit 43bb9cebec on Oct 28, 2020

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: 2024-11-26 07:15 UTC

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