fedora 24
integer weakness #2

2

Weakness Breakdown


Definition:

An integer overflow occurs when the answer to an arithmetic operation exceeds the maximum size of the integer type used to store it. The resulting value will appear to have wrapped around the maximum value and started again at the minimum value. This would look like a clock that represents 13:00 by pointing at 1:00. An attacker can use an integer overflow during a buffer length calculation, which results in the allocated buffer being too small to hold the data copied into it, thus causing a buffer overflow.

Warning code(s):

Unless checked, the resulting number can exceed the expected range.

File Name:

boo-alpha/lib/antlr-2.7.5/examples/cpp/heteroAST/INTNode.hpp

Context:

The highlighted line of code below is the trigger point of this particular Fedora 24 integer weakness.

 	int value() const
	{
		return v;
	}

	ANTLR_USE_NAMESPACE(std)string toString() const
	{
		ANTLR_USE_NAMESPACE(std)ostringstream ss;
		ss << v;
		return ss.str();
	}

	void initialize(int t, const ANTLR_USE_NAMESPACE(std)string& txt)
	{
		CalcAST::initialize(t, txt);
		v = atoi(txt.c_str());
	}
	void initialize(ANTLR_USE_NAMESPACE(antlr)RefAST t)
	{
		CalcAST::initialize(t);
	}
	void initialize(ANTLR_USE_NAMESPACE(antlr)RefToken tok)
	{
		CalcAST::initialize(tok);
		v = atoi(tok->getText().c_str());
	}
#ifdef ANTLR_SUPPORT_XML
	virtual void initialize( ANTLR_USE_NAMESPACE(std)istream& in )
	{
		CalcAST::initialize(in);
	}
#endif
	ANTLR_USE_NAMESPACE(antlr)RefAST clone( void ) const
	{
		INTNode* ast = new INTNode(*this);
		return ANTLR_USE_NAMESPACE(antlr)RefAST(ast);
	}
};

typedef ANTLR_USE_NAMESPACE(antlr)ASTRefCount<INTNode> RefINTNode;

#endif //INC_INTNode_hpp__ 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.