mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
bug fix, avatar item deserialisation unsafely assumes valid image length. caused crash on windows.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5194 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
ff6276e920
commit
94729aae4b
@ -1091,9 +1091,14 @@ RsChatAvatarItem::RsChatAvatarItem(void *data,uint32_t /*size*/)
|
||||
/* get mandatory parts first */
|
||||
ok &= getRawUInt32(data, rssize, &offset,&image_size);
|
||||
|
||||
image_data = new unsigned char[image_size] ;
|
||||
memcpy(image_data,(void*)((unsigned char*)data+offset),image_size) ;
|
||||
offset += image_size ;
|
||||
// ensure invalid image length does not overflow data
|
||||
if( (offset + image_size) <= rssize){
|
||||
image_data = new unsigned char[image_size] ;
|
||||
memcpy(image_data,(void*)((unsigned char*)data+offset),image_size) ;
|
||||
offset += image_size ;
|
||||
}else{
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (offset != rssize)
|
||||
std::cerr << "Size error while deserializing." << std::endl ;
|
||||
|
Loading…
Reference in New Issue
Block a user