Skip to content

Commit 061b561

Browse files
committed
Put isc_info_end into response buffer despite of its presence in info items.
1 parent 49eb920 commit 061b561

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/remote/client/interface.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,13 @@ unsigned char* Attachment::getWireStatsInfo(UCharBuffer& info, unsigned int buff
19841984
if (ptr >= end)
19851985
return nullptr;
19861986

1987+
if (*item == isc_info_end)
1988+
{
1989+
if (info.getCount() == 1)
1990+
info.remove(item);
1991+
break;
1992+
}
1993+
19871994
switch (*item)
19881995
{
19891996
case fb_info_wire_snd_packets:
@@ -2010,21 +2017,16 @@ unsigned char* Attachment::getWireStatsInfo(UCharBuffer& info, unsigned int buff
20102017
break;
20112018
}
20122019

2013-
case isc_info_end:
2014-
if (info.getCount() > 1)
2015-
return ptr;
2016-
2017-
*ptr++ = *item;
2018-
info.remove(item);
2019-
return nullptr;
2020-
20212020
default:
20222021
item++;
20232022
break;
20242023
}
20252024
}
20262025

2027-
return info.isEmpty() ? nullptr : ptr;
2026+
if (info.isEmpty() && ptr < end)
2027+
*ptr++ = isc_info_end;
2028+
2029+
return (info.isEmpty() || (ptr >= end)) ? nullptr : ptr;
20282030
}
20292031

20302032

src/remote/remote.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,9 @@ bool RBlobInfo::getLocalInfo(unsigned int itemsLength, const unsigned char* item
870870

871871
for (auto item = items; p && (item < items + itemsLength); item++)
872872
{
873+
if (*item == isc_info_end)
874+
break;
875+
873876
switch (*item)
874877
{
875878
case isc_info_blob_num_segments:
@@ -888,17 +891,15 @@ bool RBlobInfo::getLocalInfo(unsigned int itemsLength, const unsigned char* item
888891
p = fb_utils::putInfoItemInt(*item, blob_type, p, end);
889892
break;
890893

891-
case isc_info_end:
892-
if (p < end)
893-
*p++ = isc_info_end;
894-
break;
895-
896894
default:
897895
// unknown info item, let remote server handle it
898896
return false;
899897
}
900898
}
901899

900+
if (p < end)
901+
*p++ = isc_info_end;
902+
902903
return true;
903904
}
904905

0 commit comments

Comments
 (0)