@@ -93,7 +93,7 @@ CSD_HTFC::CSD_HTFC(hdt::IteratorUCharString *it, uint32_t blocksize,
9393
9494 // The string is explicitly copied to the
9595 // encoded sequence.
96- strncpy ((char *)(textfc + bytesfc), (char *)currentStr, currentLength );
96+ strncpy ((char *)(textfc + bytesfc), (char *)currentStr, reservedSize - bytesfc );
9797 bytesfc += currentLength;
9898
9999 // cout << nblocks-1 << "," << length << " => " << currentStr << endl;
@@ -113,7 +113,7 @@ CSD_HTFC::CSD_HTFC(hdt::IteratorUCharString *it, uint32_t blocksize,
113113
114114 // The suffix is copied to the sequence
115115 strncpy ((char *)(textfc + bytesfc), (char *)currentStr + delta,
116- currentLength - delta );
116+ reservedSize - bytesfc );
117117 bytesfc += currentLength - delta;
118118 // cout << nblocks-1 << "," << length << " => " << currentStr << endl;
119119 }
@@ -333,7 +333,7 @@ void CSD_HTFC::dumpBlock(uint block) {
333333 uint idInBlock = 0 ;
334334
335335 // Reading the first string
336- strncpy ((char *)string, (char *)(text + pos), slen );
336+ strncpy ((char *)string, (char *)(text + pos), maxlength + 1 );
337337 string[slen] = ' \0 ' ;
338338 pos += slen;
339339
@@ -352,7 +352,7 @@ void CSD_HTFC::dumpBlock(uint block) {
352352
353353 // Copying the suffix
354354 slen = strlen ((char *)text + pos) + 1 ;
355- strncpy ((char *)(string + delta), (char *)(text + pos), slen );
355+ strncpy ((char *)(string + delta), (char *)(text + pos), maxlength - delta + 1 );
356356
357357 cout << block * blocksize + idInBlock << " (" << idInBlock << " ) => "
358358 << string << " Delta=" << delta << " Len=" << slen << endl;
0 commit comments