Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro
Commits
2607476d
Commit
2607476d
authored
Sep 14, 2025
by
Chen Bill
Committed by
GitHub
Sep 14, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix buffer overflow in SetStaticText (#2925)
parent
d552e276
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
gframe/game.cpp
gframe/game.cpp
+19
-12
No files found.
gframe/game.cpp
View file @
2607476d
...
@@ -1091,41 +1091,48 @@ void Game::InitStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cWidth, i
...
@@ -1091,41 +1091,48 @@ void Game::InitStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cWidth, i
scrCardText
->
setPos
(
0
);
scrCardText
->
setPos
(
0
);
}
}
std
::
wstring
Game
::
SetStaticText
(
irr
::
gui
::
IGUIStaticText
*
pControl
,
irr
::
u32
cWidth
,
irr
::
gui
::
CGUITTFont
*
font
,
const
wchar_t
*
text
,
irr
::
u32
pos
)
{
std
::
wstring
Game
::
SetStaticText
(
irr
::
gui
::
IGUIStaticText
*
pControl
,
irr
::
u32
cWidth
,
irr
::
gui
::
CGUITTFont
*
font
,
const
wchar_t
*
text
,
irr
::
u32
pos
)
{
in
t
pbuffer
=
0
;
size_
t
pbuffer
=
0
;
irr
::
u32
_width
=
0
,
_height
=
0
;
irr
::
u32
_width
=
0
,
_height
=
0
;
wchar_t
prev
=
0
;
wchar_t
prev
=
0
;
wchar_t
strBuffer
[
4096
];
wchar_t
strBuffer
[
4096
]{};
std
::
wstring
ret
;
constexpr
size_t
buffer_len
=
sizeof
strBuffer
/
sizeof
strBuffer
[
0
]
-
1
;
const
size_t
text_len
=
std
::
wcslen
(
text
);
for
(
size_t
i
=
0
;
text
[
i
]
!=
0
&&
i
<
std
::
wcslen
(
text
);
++
i
)
{
for
(
size_t
i
=
0
;
i
<
text_len
;
++
i
)
{
if
(
pbuffer
>=
buffer_len
)
break
;
wchar_t
c
=
text
[
i
];
wchar_t
c
=
text
[
i
];
irr
::
u32
w
=
font
->
getCharDimension
(
c
).
Width
+
font
->
getKerningWidth
(
c
,
prev
);
irr
::
u32
w
=
font
->
getCharDimension
(
c
).
Width
+
font
->
getKerningWidth
(
c
,
prev
);
prev
=
c
;
prev
=
c
;
if
(
text
[
i
]
==
L'\r'
)
{
if
(
c
==
L'\r'
)
{
continue
;
continue
;
}
else
if
(
text
[
i
]
==
L'\n'
)
{
}
if
(
c
==
L'\n'
)
{
strBuffer
[
pbuffer
++
]
=
L'\n'
;
strBuffer
[
pbuffer
++
]
=
L'\n'
;
_width
=
0
;
_width
=
0
;
_height
++
;
_height
++
;
prev
=
0
;
prev
=
0
;
if
(
_height
==
pos
)
if
(
_height
==
pos
)
pbuffer
=
0
;
pbuffer
=
0
;
continue
;
continue
;
}
else
if
(
_width
>
0
&&
_width
+
w
>
cWidth
)
{
}
if
(
_width
>
0
&&
_width
+
w
>
cWidth
)
{
strBuffer
[
pbuffer
++
]
=
L'\n'
;
strBuffer
[
pbuffer
++
]
=
L'\n'
;
_width
=
0
;
_width
=
0
;
_height
++
;
_height
++
;
prev
=
0
;
prev
=
0
;
if
(
_height
==
pos
)
if
(
_height
==
pos
)
pbuffer
=
0
;
pbuffer
=
0
;
}
}
if
(
pbuffer
>=
buffer_len
)
break
;
_width
+=
w
;
_width
+=
w
;
strBuffer
[
pbuffer
++
]
=
c
;
strBuffer
[
pbuffer
++
]
=
c
;
}
}
strBuffer
[
pbuffer
]
=
0
;
strBuffer
[
pbuffer
]
=
0
;
if
(
pControl
)
pControl
->
setText
(
strBuffer
);
if
(
pControl
)
ret
.
assign
(
strBuffer
);
pControl
->
setText
(
strBuffer
);
return
ret
;
return
std
::
wstring
(
strBuffer
)
;
}
}
void
Game
::
LoadExpansions
()
{
void
Game
::
LoadExpansions
()
{
FileSystem
::
TraversalDir
(
L"./expansions"
,
[](
const
wchar_t
*
name
,
bool
isdir
)
{
FileSystem
::
TraversalDir
(
L"./expansions"
,
[](
const
wchar_t
*
name
,
bool
isdir
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment