fixed possible malloc error when the size is absurdly big (potentially caused by a deliberate attack)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7002 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-01-09 19:59:21 +00:00
parent 53b5f8222e
commit 3a567b2d6f

View File

@ -2211,6 +2211,12 @@ static int parse_literal_data(ops_region_t *region,ops_parse_info_t *pinfo)
C.literal_data_body.data = (unsigned char *)malloc(l) ;
if(C.literal_data_body.data == NULL)
{
fprintf(stderr,"parse_literal_data(): cannot malloc for requested size %d.\n",l) ;
return 0 ;
}
if(!limited_read(C.literal_data_body.data,l,region,pinfo))
{
free(C.literal_data_body.data);