From 5547b3a5eda5b3fbb322b95c30cc40944553b9ec Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 11 Feb 2009 16:33:45 +0000 Subject: [PATCH] 2009-02-12 Tatsuhiro Tsujikawa Use dynamically allocated char array to detect memory access violation. * src/DHTRoutingTableDeserializer.cc --- ChangeLog | 6 ++++++ src/DHTRoutingTableDeserializer.cc | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a21faeb0..5fb272d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-02-12 Tatsuhiro Tsujikawa + + Use dynamically allocated char array to detect memory access + violation. + * src/DHTRoutingTableDeserializer.cc + 2009-02-12 Tatsuhiro Tsujikawa Set struct sockaddr_in.sin_len if HAVE_SOCKADDR_IN_SIN_LEN is diff --git a/src/DHTRoutingTableDeserializer.cc b/src/DHTRoutingTableDeserializer.cc index 7249c562..8c03a3f9 100644 --- a/src/DHTRoutingTableDeserializer.cc +++ b/src/DHTRoutingTableDeserializer.cc @@ -33,6 +33,12 @@ */ /* copyright --> */ #include "DHTRoutingTableDeserializer.h" + +#include +#include +#include +#include + #include "DHTNode.h" #include "DHTConstants.h" #include "PeerMessageUtil.h" @@ -41,10 +47,7 @@ #include "a2netcompat.h" #include "StringFormat.h" #include "Util.h" -#include -#include -#include -#include +#include "array_fun.h" namespace aria2 { @@ -91,7 +94,12 @@ void DHTRoutingTableDeserializer::deserialize(std::istream& in) memset(zero, 0, sizeof(zero)); int version; - char buf[55]; + + // If you change the code to read more than the size of buf, then + // expand the buf size here. + char* buf = new char[255]; + array_ptr holder(buf); + // header in.read(buf, 8); if(memcmp(header, buf, 8) == 0) {