Bitcointalk

overflow bug SERIOUS

中本聪 · 2010 年 8 月 15 日

SN-2397 已核对来源,附原文与上下文。

阅读语言

这是初步的改动。看起来对吗?我还有更多要改的,这不全。稍后提交到 SVN。

Here's the preliminary change. Look right? I have more changes to make, this isn't all of it. Will SVN shortly.

bool CheckTransaction() const
    {
        // Basic checks that don't depend on any context
        if (vin.empty() || vout.empty())
            return error("CTransaction::CheckTransaction() : vin or vout empty");

        // Check for negative and overflow values
        int64 nTotal = 0;
        foreach(const CTxOut& txout, vout)
        {
            if (txout.nValue < 0)
                return error("CTransaction::CheckTransaction() : txout.nValue negative");
            if (txout.nValue > 21000000 * COIN)
                return error("CTransaction::CheckTransaction() : txout.nValue too high");
            nTotal += txout.nValue;
            if (nTotal > 21000000 * COIN)
                return error("CTransaction::CheckTransaction() : txout total too high");
        }

        if (IsCoinBase())
        {
            if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
                return error("CTransaction::CheckTransaction() : coinbase script size");
        }
        else
        {
            foreach(const CTxIn& txin, vin)
                if (txin.prevout.IsNull())
                    return error("CTransaction::CheckTransaction() : prevout is null");
        }

        return true;
    }

别把主题设为置顶,没人会往上看。到时自然会有足够的回帖把它顶起来。

Don't sticky the topic, nobody looks up there. There'll be enough posts to bump.

来源
Bitcointalk 原始链接 ↗ 记录编号 SN-2397

阅读字号

选择适合你的字号,之后阅读会继续使用。