Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/jrd/filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,6 @@ static ISC_STATUS string_filter(USHORT action, BlobControl* control)
*
**************************************/
filter_tmp* string;
USHORT length;

switch (action)
{
Expand All @@ -1322,10 +1321,14 @@ static ISC_STATUS string_filter(USHORT action, BlobControl* control)
return FB_SUCCESS;

case isc_blob_filter_get_segment:
{
if (!(string = (filter_tmp*) control->ctl_data[1]))
return isc_segstr_eof;
length = string->tmp_length - control->ctl_data[2];
if (length > control->ctl_buffer_length)

USHORT length = string->tmp_length - control->ctl_data[2];
const bool outOfBuffer = (length > control->ctl_buffer_length);

if (outOfBuffer)
length = control->ctl_buffer_length;
memcpy(control->ctl_buffer, string->tmp_string + (USHORT) control->ctl_data[2], length);
control->ctl_data[2] += length;
Expand All @@ -1334,7 +1337,8 @@ static ISC_STATUS string_filter(USHORT action, BlobControl* control)
control->ctl_data[2] = 0;
}
control->ctl_segment_length = length;
return (length <= control->ctl_buffer_length) ? FB_SUCCESS : isc_segment;
return (!outOfBuffer) ? FB_SUCCESS : isc_segment;
}

case isc_blob_filter_put_segment:
case isc_blob_filter_create:
Expand Down
Loading