Make sure that GetRandomBytes never fails #5239

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2014_11_getrandbytes changing 3 files +5 −8
  1. laanwj commented at 12:51 PM on November 7, 2014: member

    The code uses GetRandomBytes in several contexts where it's either unwieldy to return an error, or an error would mean a fatal exception anyhow. Bitcoin can't cope gracefully with a failing RNG. So just fail with an assertion error. @gmaxwell checked OpenSSL a while ago and discovered that it never actually fails, but it can't hurt to be a bit paranoid here.

    (somehow this gives me a deja-vu, I remember we did this before? can't find it in git history though)

  2. Make sure that GetRandomBytes never fails
    We're using GetRandomBytes in several contexts where it's either
    unwieldy to return an error, or an error would mean a fatal exception
    anyhow.
    
    @gmaxwell checked OpenSSL a while ago and discovered that it never
    actually fails, but it can't hurt to be a bit paranoid here.
    65e3a1e762
  3. laanwj added the label Priority Medium on Nov 7, 2014
  4. gmaxwell commented at 4:47 PM on November 7, 2014: contributor

    Increases our reliance on being compiled with assert() for correct behavior in some abstract sense. I'm not sure if I care given that it will not fail.

  5. sipa commented at 5:43 PM on November 7, 2014: member

    utACK - we're already relying on assert, and test for it. If we ever want to get rid of it, it's obvious where in code changes are needed.

  6. jgarzik commented at 6:19 PM on November 7, 2014: contributor

    ut ACK

  7. gmaxwell commented at 7:02 PM on November 8, 2014: contributor

    utACK

  8. TheBlueMatt commented at 7:28 PM on November 8, 2014: member

    Tested ACK only commithash 65e3a1e76202b9a695fc6319dbd527ac563e0895: http://bitcoin.ninja/TheBlueMatt-5239.txt

  9. laanwj commented at 4:25 PM on November 10, 2014: member

    Right - we need to replace asserts with a macro that calls to a custom function that cannot be compiled out at some point.

  10. laanwj merged this on Nov 10, 2014
  11. laanwj closed this on Nov 10, 2014

  12. laanwj referenced this in commit 33d5ee6830 on Nov 10, 2014
  13. MarcoFalke locked this on Sep 8, 2021

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-04-13 15:15 UTC

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