|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 1/8] log: Avoid buffer overrun in DbgPrint interception
On 14/08/2026 09:30, Owen Smith wrote:
> Truncate incomming strings to fit inside a Slot's Buffer
>
> Assisted-by: ClaudeCode:claude-opus-4.8
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
Reviewed-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
> ---
> src/xen/log.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/xen/log.c b/src/xen/log.c
> index 8673105..93039f6 100644
> --- a/src/xen/log.c
> +++ b/src/xen/log.c
> @@ -545,6 +545,7 @@ LogDebugPrint(
> {
> PLOG_CONTEXT Context = &LogContext;
> KIRQL Irql;
> + ULONG Length;
> PLOG_SLOT Slot;
>
> UNREFERENCED_PARAMETER(ComponentId);
> @@ -571,9 +572,14 @@ LogDebugPrint(
>
> Slot = &Context->Slot[Context->Pending++];
>
> + // truncate long log lines - avoid buffer overrun on Slot->Buffer
> + Length = Ansi->Length >= LOG_BUFFER_SIZE ?
> + LOG_BUFFER_SIZE - 1:
> + Ansi->Length;
> +
> Slot->Level = 1 << Level;
> - RtlCopyMemory(Slot->Buffer, Ansi->Buffer, Ansi->Length);
> - Slot->Offset = Ansi->Length;
> + RtlCopyMemory(Slot->Buffer, Ansi->Buffer, Length);
> + Slot->Offset = Length;
>
> ReleaseHighLock(&Context->Lock, Irql);
>
--
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |