Wrong file open mode #11745

issue Elbandi openend this issue on November 21, 2017
  1. Elbandi commented at 4:53 pm on November 21, 2017: contributor

    Block and undo files are open by OpenDiskFile, there is a read only parameter. But in fopen function call, “rb+” mode is read-or-write mode, read-only paramter is ignored, so it always open for write. https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L3467

    from fopen man:

    r+ or rb+ or r+b
      Open file for update (reading and writing).
    w+ or wb+ or w+b
      Truncate to zero length or create file for update.
    

    Is this a bug or feature?

    (old times in readonly open, fopen is called by “rb” mode: https://github.com/bitcoin/bitcoin/commit/5382bcf8cd23c36a435c29080770a79b5e28af42#diff-e8db9b851adc2422aadfffca88f14c91L635)

  2. sipa commented at 7:26 pm on November 21, 2017: member
    This looks like a bug.
  3. fanquake added the label Bug on Nov 23, 2017
  4. laanwj commented at 11:00 am on November 29, 2017: member
    Fixed by #11747
  5. laanwj closed this on Nov 29, 2017

  6. 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: 2024-11-23 12:12 UTC

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