mirror of https://github.com/aria2/aria2
2007-12-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that prevents aria2 from loading cookie file when expire value is greater than 2^31-1. BUG#1851066 * src/CookieBoxFactory.cc * test/CookieBoxFactoryTest.ccpull/1/head
parent
3ea4fe447a
commit
1e63b1cda5
|
@ -1,3 +1,10 @@
|
|||
2007-12-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Fixed the bug that prevents aria2 from loading cookie file when expire
|
||||
value is greater than 2^31-1. BUG#1851066
|
||||
* src/CookieBoxFactory.cc
|
||||
* test/CookieBoxFactoryTest.cc
|
||||
|
||||
2007-12-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Fixed possible memory leak when an exception is thrown.
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "CookieBoxFactory.h"
|
||||
#include "CookieParser.h"
|
||||
#include "Util.h"
|
||||
#include "RecoverableException.h"
|
||||
|
||||
CookieBoxHandle CookieBoxFactory::createNewInstance()
|
||||
{
|
||||
|
@ -50,9 +51,15 @@ void CookieBoxFactory::loadDefaultCookie(istream& s)
|
|||
if(Util::startsWith(line, "#")) {
|
||||
continue;
|
||||
}
|
||||
Cookie c = parseNsCookie(line);
|
||||
if(c.good()) {
|
||||
defaultCookies.push_back(c);
|
||||
try {
|
||||
Cookie c = parseNsCookie(line);
|
||||
if(c.good()) {
|
||||
defaultCookies.push_back(c);
|
||||
}
|
||||
} catch(RecoverableException* e) {
|
||||
// ignore malformed cookie entry
|
||||
// TODO better to log it
|
||||
delete e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +75,12 @@ Cookie CookieBoxFactory::parseNsCookie(const string& nsCookieStr) const
|
|||
c.domain = vs[0];
|
||||
c.path = vs[2];
|
||||
c.secure = vs[3] == "TRUE" ? true : false;
|
||||
c.expires = Util::parseInt(vs[4]);
|
||||
int64_t expireDate = Util::parseLLInt(vs[4]);
|
||||
// TODO assuming time_t is int32_t...
|
||||
if(expireDate > INT32_MAX) {
|
||||
expireDate = INT32_MAX;
|
||||
}
|
||||
c.expires = expireDate;
|
||||
c.name = vs[5];
|
||||
if(vs.size() >= 7) {
|
||||
c.value = vs[6];
|
||||
|
|
|
@ -38,18 +38,30 @@ void CookieBoxFactoryTest::testLoadDefaultCookie()
|
|||
Cookie c = cookies[0];
|
||||
CPPUNIT_ASSERT_EQUAL(string("JSESSIONID"), c.name);
|
||||
CPPUNIT_ASSERT_EQUAL(string("123456789"), c.value);
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1181473200, c.expires);
|
||||
CPPUNIT_ASSERT_EQUAL(string("/"), c.path);
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), c.domain);
|
||||
|
||||
c = cookies[1];
|
||||
CPPUNIT_ASSERT_EQUAL(string("user"), c.name);
|
||||
CPPUNIT_ASSERT_EQUAL(string("me"), c.value);
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1181473200, c.expires);
|
||||
CPPUNIT_ASSERT_EQUAL(string("/"), c.path);
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), c.domain);
|
||||
|
||||
c = cookies[2];
|
||||
CPPUNIT_ASSERT_EQUAL(string("passwd"), c.name);
|
||||
CPPUNIT_ASSERT_EQUAL(string("secret"), c.value);
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)2147483647, c.expires);
|
||||
CPPUNIT_ASSERT_EQUAL(string("/cgi-bin"), c.path);
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), c.domain);
|
||||
|
||||
c = cookies[3];
|
||||
CPPUNIT_ASSERT_EQUAL(string("novalue"), c.name);
|
||||
CPPUNIT_ASSERT_EQUAL(string(""), c.value);
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)2147483647, c.expires);
|
||||
CPPUNIT_ASSERT_EQUAL(string("/"), c.path);
|
||||
CPPUNIT_ASSERT_EQUAL(string("localhost"), c.domain);
|
||||
}
|
||||
|
||||
void CookieBoxFactoryTest::testCreateNewInstance()
|
||||
|
@ -60,5 +72,5 @@ void CookieBoxFactoryTest::testCreateNewInstance()
|
|||
CookieBoxHandle box = factory.createNewInstance();
|
||||
Cookies cookies = box->criteriaFind("localhost", "/", 0, true);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)4, (int32_t)cookies.size());
|
||||
CPPUNIT_ASSERT_EQUAL((int32_t)3, (int32_t)cookies.size());
|
||||
}
|
||||
|
|
|
@ -3,5 +3,6 @@ localhost FALSE / TRUE 1181473200 JSESSIONID 123456789
|
|||
|
||||
localhost FALSE / FALSE 1181473200 user me
|
||||
|
||||
localhost FALSE / FALSE 1181473200 passwd secret
|
||||
localhost FALSE / FALSE 1181473200 novalue
|
||||
localhost FALSE /cgi-bin FALSE 2147483647 passwd secret
|
||||
overflow FALSE / FALSE FALSE 9223372036854775807 TAX 1000
|
||||
localhost FALSE / FALSE 2147483648 novalue
|
Loading…
Reference in New Issue