From 64b8f90120b3f07c59ef85468ee46bd2cb3ec7eb Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 22 Feb 2011 19:38:53 +0000 Subject: [PATCH] added a check to make the code robust to structural errors in bd messages git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4048 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libbitdht/src/bitdht/bdmsgs.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libbitdht/src/bitdht/bdmsgs.cc b/libbitdht/src/bitdht/bdmsgs.cc index ad500bda2..daccc95da 100644 --- a/libbitdht/src/bitdht/bdmsgs.cc +++ b/libbitdht/src/bitdht/bdmsgs.cc @@ -24,6 +24,7 @@ */ #include +#include #include #include "bitdht/bencode.h" #include "bitdht/bdmsgs.h" @@ -646,6 +647,10 @@ int beMsgGetToken(be_node *n, bdToken &token) return 0; } int len = be_str_len(n); + + if(len > BITDHT_TOKEN_MAX_LEN) + return 0 ; + for(int i = 0; i < len; i++) { token.data[i] = n->val.s[i];