Skip to content

size string copies by str_len in copy_str_to_string_list#1926

Merged
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:string-copy-alloc-size
Jun 8, 2026
Merged

size string copies by str_len in copy_str_to_string_list#1926
charles-lunarg merged 1 commit into
KhronosGroup:mainfrom
aizu-m:string-copy-alloc-size

Conversation

@aizu-m

@aizu-m aizu-m commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

copy_str_to_string_list / copy_str_to_start_of_string_list, sizing a 57-byte manifest path:

sizeof(char *) * str_len + 1  ->  8 * 57 + 1 = 457 bytes to hold a 58-byte string

str_len is the length of one string, not a count of pointers. The sizeof(char ) factor belongs to create_string_list right above, which allocates the char array, and got copied into these two char-buffer allocations. Every manifest path and enabled layer name copied through them lands in a buffer about eight times larger than needed. The loader_strncpy bound uses the same inflated size, so nothing overflows, it just over-allocates.

Spotted while reading the string-list helpers next to create_string_list. Size both buffers by str_len + 1 to match the element.

@ci-tester-lunarg

Copy link
Copy Markdown

Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

1 similar comment
@ci-tester-lunarg

Copy link
Copy Markdown

Author aizu-m not on autobuild list. Waiting for curator authorization before starting CI build.

@charles-lunarg charles-lunarg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Whoops, I'm sure I meant sizeof(char) instead. But considering that is basically always 1, and when its not, we have to do more work than just adjust the size (looking at you windows), there isn't a great reason to keep the sizeof.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 764221.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3531 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3531 passed.

@charles-lunarg charles-lunarg merged commit dd42aa7 into KhronosGroup:main Jun 8, 2026
85 of 86 checks passed
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.

3 participants