mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed dangerous memcpy in RsTurtleGenericSearchResultItem::clone() function
This commit is contained in:
parent
18eee374f1
commit
9c90b32def
@ -100,15 +100,20 @@ void RsTurtleGenericSearchRequestItem::serial_process(RsGenericSerializer::Seria
|
||||
}
|
||||
RsTurtleSearchRequestItem *RsTurtleGenericSearchRequestItem::clone() const
|
||||
{
|
||||
RsTurtleGenericSearchRequestItem *sr = new RsTurtleGenericSearchRequestItem ;
|
||||
|
||||
memcpy(sr,this,sizeof(RsTurtleGenericSearchRequestItem)) ;
|
||||
|
||||
sr->search_data = (unsigned char*)rs_malloc(search_data_len) ;
|
||||
memcpy(sr->search_data,search_data,search_data_len) ;
|
||||
|
||||
return sr ;
|
||||
return new RsTurtleGenericSearchRequestItem(*this) ;
|
||||
}
|
||||
|
||||
RsTurtleGenericSearchRequestItem::RsTurtleGenericSearchRequestItem(const RsTurtleGenericSearchRequestItem& it)
|
||||
: RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST)
|
||||
{
|
||||
search_data_len = it.search_data_len ;
|
||||
search_data = (unsigned char*)rs_malloc(it.search_data_len) ;
|
||||
service_id = it.service_id ;
|
||||
request_type = it.request_type ;
|
||||
|
||||
memcpy(search_data,it.search_data,it.search_data_len) ;
|
||||
}
|
||||
|
||||
template<> uint32_t RsTypeSerializer::serial_size(const RsRegularExpression::LinearizedExpression& r)
|
||||
{
|
||||
uint32_t s = 0 ;
|
||||
|
@ -185,7 +185,7 @@ class RsTurtleGenericSearchRequestItem: public RsTurtleSearchRequestItem
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
private:
|
||||
RsTurtleGenericSearchRequestItem(const RsTurtleGenericSearchRequestItem&): RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST) {} // make the object non copi-able.
|
||||
RsTurtleGenericSearchRequestItem(const RsTurtleGenericSearchRequestItem&); // make the object non copi-able.
|
||||
RsTurtleGenericSearchRequestItem& operator=(const RsTurtleGenericSearchRequestItem&) { return *this;}
|
||||
};
|
||||
class RsTurtleSearchResultItem: public RsTurtleItem
|
||||
|
Loading…
Reference in New Issue
Block a user