Commit 756402a7 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

do not rely on ID string being present at byte offset 0

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.

SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 3843
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 5ea9a0e4
......@@ -218,8 +218,17 @@ namespace fapidxx {
*/
void WID2container::setwid2(char *fstring, ftnlen slen)
{
/*
* copy content immediately such that we do not rely on the ID string
* being placed at byte offset 0 in WID2container::WID2struct
*/
int w2size=sizeof(WID2container::WID2struct);
FAPIDXX_assert(w2size<=slen,
"WID2container::setwid2: string is too short");
WID2container::WID2struct* ws=new WID2container::WID2struct;
std::memcpy(ws, fstring, w2size);
// check for special ID
if (std::strncmp(fstring, WID2container::WID2struct::encodeID,
if (std::strncmp(ws->ID, WID2container::WID2struct::encodeID,
WID2container::WID2struct::idlen)!=0)
{
this->setwid2(stringfromfstring(fstring, slen));
......@@ -232,14 +241,9 @@ namespace fapidxx {
* in memory, copy the memory contents fstring points to into
* this struct and read the WID2 data from it.
*/
int w2size=sizeof(WID2container::WID2struct);
FAPIDXX_assert(w2size<=slen,
"WID2container::setwid2: string is too short");
WID2container::WID2struct* ws=new WID2container::WID2struct;
std::memcpy(ws, fstring, w2size);
this->wid2=ws->get();
delete ws;
}
delete ws;
} // void WID2container::setwid2(char *fstring, ftnlen slen)
/*----------------------------------------------------------------------*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment