mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-16 16:14:47 -04:00
Fix possible unaligned access to UCS2 strings
This commit is contained in:
parent
20d0155130
commit
c9939e23ec
7 changed files with 47 additions and 66 deletions
|
@ -373,16 +373,6 @@ struct CBString : public tagbstring {
|
|||
CBString mid(int pos, int len) const { return midstr(pos, len); }
|
||||
CBString chopped(int len) const { return midstr(slen - len, len); }
|
||||
void chop(int len) { trunc(((slen > len) ? slen - len : 0)); }
|
||||
static CBString fromUtf16(const unsigned short* str) {
|
||||
// Naive implementation assuming that only ASCII LE part of UCS2 is used, str may not be aligned.
|
||||
CBString msg;
|
||||
const char *str8 = reinterpret_cast<const char *>(str);
|
||||
while (str8[0]) {
|
||||
msg += str8[0];
|
||||
str8 += 2;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
CBString leftJustified(int length) { if (length > slen) { return *this + CBString(' ', length - slen); } return *this; }
|
||||
};
|
||||
extern const CBString operator + (const char *a, const CBString& b);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue