Coder Social home page Coder Social logo

Comments (2)

jabbervorx avatar jabbervorx commented on June 12, 2024

I still don't know anything about Python or Bitcoin internals, but, based on some comment from bitcoin talk I propose following fix:

--- deserialize.py~bak  2013-10-28 15:15:38.605861382 +0100
+++ deserialize.py      2013-10-28 15:17:35.241426261 +0100
@@ -244,14 +244,26 @@
     if opcode <= opcodes.OP_PUSHDATA4:
       nSize = opcode
       if opcode == opcodes.OP_PUSHDATA1:
-        nSize = ord(bytes[i])
-        i += 1
+        if i + 1 > len(bytes):
+          vch = "_INVALID_NULL"
+          i = len(bytes)
+        else:
+          nSize = ord(bytes[i])
+          i += 1
       elif opcode == opcodes.OP_PUSHDATA2:
-        (nSize,) = struct.unpack_from('<H', bytes, i)
-        i += 2
+        if i + 2 > len(bytes):
+          vch = "_INVALID_NULL"
+          i = len(bytes)
+        else:
+          (nSize,) = struct.unpack_from('<H', bytes, i)
+          i += 2
       elif opcode == opcodes.OP_PUSHDATA4:
-        (nSize,) = struct.unpack_from('<I', bytes, i)
-        i += 4
+        if i + 4 > len(bytes):
+          vch = "_INVALID_NULL"
+          i = len(bytes)
+        else:
+          (nSize,) = struct.unpack_from('<I', bytes, i)
+          i += 4
       if i+nSize > len(bytes):
         vch = "_INVALID_"+bytes[i:]
         i = len(bytes)

from bitcoin-abe.

dermoth avatar dermoth commented on June 12, 2024

Thanks. I don't have very strong knowledge of Bitcoin neither, but this patch looks OK. I'll make a pull request off it for now, while I let Abe load the remaining blocks with the patch applied. Once done i'll compare some stats and merge if all looks good.

Regards,

Thomas

from bitcoin-abe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.