Skip to content

Conversation

@avagin
Copy link
Member

@avagin avagin commented Nov 11, 2025

vsnprintf does not always return the number of bytes actually written to the buffer.

If the output was truncated due to the buffer limit, the return value is the total number of bytes which WOULD have been written to the final string if enough space had been available.

This means we must cap the return value to the buffer size excluding the terminating null byte to correctly calculate the log entry size.

Fixes #2781

@avagin avagin requested a review from Copilot November 11, 2025 23:17
@avagin avagin marked this pull request as draft November 11, 2025 23:18
vsnprintf does not always return the number of bytes actually written to
the buffer.

If the output was truncated due to the buffer limit, the return value is
the total number of bytes which WOULD have been written to the final
string if enough space had been available.

This means we must cap the return value to the buffer size excluding the
terminating null byte to correctly calculate the log entry size.

Signed-off-by: Andrei Vagin <avagin@google.com>
@avagin avagin force-pushed the criu-log-sprintf-ret branch from d138c94 to cdff770 Compare November 11, 2025 23:21
Copilot finished reviewing on behalf of avagin November 11, 2025 23:23
@avagin avagin marked this pull request as ready for review November 11, 2025 23:41
@avagin avagin requested review from kolyshkin and rst0git November 11, 2025 23:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Member

@rst0git rst0git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I was able to confirm that this change fixes the error in #2781

@avagin avagin requested a review from Copilot November 12, 2025 00:45
Copilot finished reviewing on behalf of avagin November 12, 2025 00:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more (minor) issue found.

Using sizeof(hdr) where hdr is a pointer gives the size of the pointer,
not the size of the structure it points to.

Reported-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
@avagin avagin requested a review from Copilot November 12, 2025 05:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@avagin avagin merged commit a1fd7e6 into criu-dev Nov 12, 2025
66 of 78 checks passed
@avagin avagin deleted the criu-log-sprintf-ret branch November 12, 2025 06:36
Copilot finished reviewing on behalf of avagin November 12, 2025 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runc tests fail with criu-dev

4 participants