BIP-174: test data: fix value length #867

pull dgpv wants to merge 1 commits into bitcoin:master from dgpv:patch-7 changing 1 files +2 −2
  1. dgpv commented at 12:31 PM on December 9, 2019: contributor

    In the test case "Case: PSBT With invalid output witnessScript typed key", after PSBT_OUT_WITNESS_SCRIPT key with garbage data (which ends with ...478ef51309d, follows value 2b which would denote the length of the data value of the key-value pair. But the length of actual remaining data is only 7 bytes. Thus, an implementation that reads key-value pairs and checks for validity of the key data after it has read the current key-value pair, will not be able to hit the exact condition intended for this test case: extra data within the key itself. This is because such implementation will hit serialization error when it will try to read the data of the value and will get the short read.

    Reading full key-value pair and then checking key format afterwards is fairly normal thing to do, as the format of the keys with all their meaning is an abstraction of higher level than just the simple key-value serialization format.

    The proposed change is to replace byte 2b after the key data to 06 and thus make the value length in the key-value pair valid (not going beyond the end of the data).

    base64 encoding has been changed accordingly.

  2. BIP-174: test data: fix value length
    In the test case "Case: PSBT With invalid output witnessScript typed key", after PSBT_OUT_WITNESS_SCRIPT key with garbage data (which ends with `...478ef51309d`, follows value `2b` which would denote the length of the data value of the key. But the length of actual remaining data is only 7 bytes. Thus, an implementation that reads key-value pairs and checks for validity of the key data after it has read the current key-value pair, will not be able to hit the exact condition intended for this test case: extra data within the key itself. This is because such implementation will hit serialization error when it will try to read the data of the value and will get the short read.
    
    Reading full key-value pair and then checking key format afterwards is fairly normal thing to do, as the format of the keys with all their meaning is an abstraction of higher level than just the simple key-value serialization format.
    
    The proposed change is to replace byte `2b` after the key data to `06` and thus make the value length in the key-value pair valid (not going beyond the end of the data).
    
    base64 encoding has been changed accordingly.
    65f0b3dd62
  3. achow101 commented at 6:02 PM on December 9, 2019: member

    ACK 65f0b3dd62ecc55e43436173c5f84e893809d0fa

  4. luke-jr merged this on Dec 13, 2019
  5. luke-jr closed this on Dec 13, 2019

Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 07:10 UTC

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