nfqws: backport QUICDefragCrypto

This commit is contained in:
bol-van
2026-03-05 10:32:26 +03:00
parent a92b4a543e
commit acccfc75e9

View File

@@ -888,28 +888,27 @@ bool QUICDefragCrypto(const uint8_t *clean,size_t clean_len, uint8_t *defrag,siz
if ((pos+sz)>clean_len) return false; if ((pos+sz)>clean_len) return false;
if ((offset+sz)>defrag_data_len) return false; // defrag buf overflow if ((offset+sz)>defrag_data_len) return false; // defrag buf overflow
// remove exact duplicates early to save cpu
for(i=0;i<range;i++)
if (ranges[i].offset==offset && ranges[i].len==sz)
goto skip_range;
if (zeropos < offset) if (zeropos < offset)
// make sure no uninitialized gaps exist in case of not full fragment coverage // make sure no uninitialized gaps exist in case of not full fragment coverage
memset(defrag_data+zeropos,0,offset-zeropos); memset(defrag_data+zeropos,0,offset-zeropos);
if ((offset+sz) > zeropos) if ((offset+sz) > zeropos)
zeropos=offset+sz; zeropos=offset+sz;
memcpy(defrag_data+offset,clean+pos,sz);
if ((offset+sz) > szmax) szmax = offset+sz;
found=true; found=true;
pos+=sz; if ((offset+sz) > szmax) szmax = offset+sz;
memcpy(defrag_data+offset,clean+pos,sz);
// remove exact duplicates early to save cpu
for(i=0;i<range;i++)
if (ranges[i].offset==offset && ranges[i].len==sz)
goto endloop;
ranges[range].offset = offset; ranges[range].offset = offset;
ranges[range].len = sz; ranges[range].len = sz;
range++; range++;
skip_range:
pos+=sz;
} }
endloop:
} }
if (found) if (found)
{ {