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
This commit is contained in:
csoler 2011-02-22 19:38:53 +00:00
parent 3be6ddb8df
commit 64b8f90120

View File

@ -24,6 +24,7 @@
*/
#include <stdio.h>
#include <assert.h>
#include <string.h>
#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];