mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
[winpr,stream] Add Stream_ResetPosition
A helper function that does not require return checks, in contrast to Stream_SetPosition, which might fail.
This commit is contained in:
@@ -334,7 +334,7 @@ static PfChannelResult DynvcTrackerPeekHandleByMode(ChannelStateTracker* tracker
|
||||
trackerState->CurrentDataReceived = 0;
|
||||
|
||||
if (dynChannel->packetReassembly && trackerState->currentPacket)
|
||||
Stream_SetPosition(trackerState->currentPacket, 0);
|
||||
Stream_ResetPosition(trackerState->currentPacket);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -551,7 +551,7 @@ static PfChannelResult DynvcTrackerHandleCmdDATA(ChannelStateTracker* tracker,
|
||||
if (dynChannel->packetReassembly)
|
||||
{
|
||||
if (trackerState->currentPacket)
|
||||
Stream_SetPosition(trackerState->currentPacket, 0);
|
||||
Stream_ResetPosition(trackerState->currentPacket);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -199,8 +199,8 @@ static wStream* rdpdr_get_send_buffer(pf_channel_common_context* rdpdr, UINT16 c
|
||||
{
|
||||
WINPR_ASSERT(rdpdr);
|
||||
WINPR_ASSERT(rdpdr->s);
|
||||
if (!Stream_SetPosition(rdpdr->s, 0))
|
||||
return nullptr;
|
||||
Stream_ResetPosition(rdpdr->s);
|
||||
|
||||
if (!Stream_EnsureCapacity(rdpdr->s, capacity + 4))
|
||||
return nullptr;
|
||||
Stream_Write_UINT16(rdpdr->s, component);
|
||||
@@ -1068,7 +1068,7 @@ static BOOL pf_channel_rdpdr_rewrite_device_list_to(wStream* s, UINT32 fromVersi
|
||||
Stream_Copy(s, clone, cap);
|
||||
Stream_SealLength(clone);
|
||||
|
||||
Stream_SetPosition(clone, 0);
|
||||
Stream_ResetPosition(clone);
|
||||
Stream_SetPosition(s, pos);
|
||||
}
|
||||
|
||||
@@ -1148,7 +1148,7 @@ static BOOL pf_channel_rdpdr_rewrite_device_list(pf_channel_client_context* rdpd
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
UINT16 component = 0;
|
||||
UINT16 packetid = 0;
|
||||
Stream_SetPosition(s, 0);
|
||||
Stream_ResetPosition(s);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(rdpdr->log, s, 4))
|
||||
return FALSE;
|
||||
@@ -1381,7 +1381,7 @@ BOOL pf_channel_rdpdr_client_handle(pClientContext* pc, UINT16 channelId, const
|
||||
}
|
||||
s = rdpdr->common.buffer;
|
||||
if (flags & CHANNEL_FLAG_FIRST)
|
||||
Stream_SetPosition(s, 0);
|
||||
Stream_ResetPosition(s);
|
||||
if (!Stream_EnsureRemainingCapacity(s, xsize))
|
||||
{
|
||||
CLIENT_RX_LOG(rdpdr->log, WLOG_ERROR,
|
||||
@@ -1394,7 +1394,7 @@ BOOL pf_channel_rdpdr_client_handle(pClientContext* pc, UINT16 channelId, const
|
||||
return TRUE;
|
||||
|
||||
Stream_SealLength(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
Stream_ResetPosition(s);
|
||||
if (Stream_Length(s) != totalSize)
|
||||
{
|
||||
CLIENT_RX_LOG(rdpdr->log, WLOG_WARN,
|
||||
@@ -1919,7 +1919,7 @@ BOOL pf_channel_rdpdr_server_handle(pServerContext* ps, UINT16 channelId, const
|
||||
s = rdpdr->common.buffer;
|
||||
|
||||
if (flags & CHANNEL_FLAG_FIRST)
|
||||
Stream_SetPosition(s, 0);
|
||||
Stream_ResetPosition(s);
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, xsize))
|
||||
return FALSE;
|
||||
@@ -1929,7 +1929,7 @@ BOOL pf_channel_rdpdr_server_handle(pServerContext* ps, UINT16 channelId, const
|
||||
return TRUE;
|
||||
|
||||
Stream_SealLength(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
Stream_ResetPosition(s);
|
||||
|
||||
if (Stream_Length(s) != totalSize)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ static BOOL pf_channel_client_write_iostatus(wStream* out, const SMARTCARD_OPERA
|
||||
WINPR_ASSERT(out);
|
||||
|
||||
pos = Stream_GetPosition(out);
|
||||
Stream_SetPosition(out, 0);
|
||||
Stream_ResetPosition(out);
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, out, 16))
|
||||
return FALSE;
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ class DynChannelState
|
||||
[[nodiscard]] static BOOL drdynvc_try_read_header(wStream* s, uint32_t& channelId, size_t& length)
|
||||
{
|
||||
UINT8 value = 0;
|
||||
Stream_SetPosition(s, 0);
|
||||
Stream_ResetPosition(s);
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
Stream_Read_UINT8(s, value);
|
||||
|
||||
@@ -60,7 +60,7 @@ static BOOL channelTracker_resetCurrentPacket(ChannelStateTracker* tracker)
|
||||
tracker->currentPacket = Stream_New(nullptr, 10ULL * 1024ULL);
|
||||
if (!tracker->currentPacket)
|
||||
return FALSE;
|
||||
Stream_SetPosition(tracker->currentPacket, 0);
|
||||
Stream_ResetPosition(tracker->currentPacket);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -923,7 +923,7 @@ static int pf_client_verify_X509_certificate(freerdp* instance, const BYTE* data
|
||||
|
||||
if (!Stream_EnsureCapacity(pc->remote_pem, length))
|
||||
return 0;
|
||||
Stream_SetPosition(pc->remote_pem, 0);
|
||||
Stream_ResetPosition(pc->remote_pem);
|
||||
|
||||
free(pc->remote_hostname);
|
||||
pc->remote_hostname = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user