Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ static void createImage(ImageSettings settings, const uint8_t* stage2, uint32_t
// If total size is less than 64 kB, duplicate the content to the next 64 kB.
// This cheap fix makes it possible to use fake memory cards with a 512 kbits (64 kB) chip.
if (payloadOffset + payload.size() <= out.size() / 2) {
std::memcpy(out.data() + out.size() / 2, out.data(), out.size() / 2);
memcpy(out.data() + out.size() / 2, out.data(), out.size() / 2);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe:
const size_t half_size = out.size() >> 1;
memcpy(out.data() + half_size, out.data(), half_size);

} else {
printf("Note: payload size is more than half the card size.\n");
}
Expand Down