From f316c947100f7683f4ca9ba1c71bb1446433dbb4 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 17 Mar 2016 23:28:28 +0900 Subject: Ignore floating number in torrent file --- test/ValueBaseBencodeParserTest.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ValueBaseBencodeParserTest.cc') diff --git a/test/ValueBaseBencodeParserTest.cc b/test/ValueBaseBencodeParserTest.cc index a24af6d3..30cca2f4 100644 --- a/test/ValueBaseBencodeParserTest.cc +++ b/test/ValueBaseBencodeParserTest.cc @@ -3,6 +3,7 @@ #include #include "ValueBase.h" +#include "BencodeParser.h" namespace aria2 { @@ -77,6 +78,12 @@ void ValueBaseBencodeParserTest::testParseUpdate() CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775807LL, downcast(s)->i()); } + { + // float number, ignored and always 0. + std::string src = "i+343243.342E-1333e"; + auto s = parser.parseFinal(src.c_str(), src.size(), error); + CPPUNIT_ASSERT_EQUAL((int64_t)0, downcast(s)->i()); + } { // dict, size 1 std::string src = "d3:fooi123ee"; @@ -187,6 +194,11 @@ void ValueBaseBencodeParserTest::testParseUpdate() checkDecodeError(std::string(51, 'l') + std::string(51, 'e')); checkDecodeError(std::string(50, 'l') + "d3:fooi100ee" + std::string(50, 'e')); + // float number, but including bad characters + checkDecodeError("i-1.134a+33e"); + checkDecodeError("ixe"); + // empty number + checkDecodeError("ie"); { // ignore trailing garbage at the end of the input. std::string src = "5:aria2trail"; -- cgit