Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
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-core
Commits
9e7c8ca8
Commit
9e7c8ca8
authored
Aug 29, 2016
by
VanillaSalt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use strncpy() instead of sprintf()
parent
034105cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
8 deletions
+13
-8
interpreter.cpp
interpreter.cpp
+7
-7
interpreter.h
interpreter.h
+5
-0
libdebug.cpp
libdebug.cpp
+1
-1
No files found.
interpreter.cpp
View file @
9e7c8ca8
...
@@ -645,7 +645,7 @@ int32 interpreter::load_script(char* script_name) {
...
@@ -645,7 +645,7 @@ int32 interpreter::load_script(char* script_name) {
no_action
++
;
no_action
++
;
error
=
luaL_loadbuffer
(
current_state
,
(
const
char
*
)
buffer
,
len
,
(
const
char
*
)
script_name
)
||
lua_pcall
(
current_state
,
0
,
0
,
0
);
error
=
luaL_loadbuffer
(
current_state
,
(
const
char
*
)
buffer
,
len
,
(
const
char
*
)
script_name
)
||
lua_pcall
(
current_state
,
0
,
0
,
0
);
if
(
error
)
{
if
(
error
)
{
sprintf
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
no_action
--
;
...
@@ -780,7 +780,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count)
...
@@ -780,7 +780,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count)
call_depth
++
;
call_depth
++
;
push_param
(
current_state
);
push_param
(
current_state
);
if
(
lua_pcall
(
current_state
,
param_count
,
ret_count
,
0
))
{
if
(
lua_pcall
(
current_state
,
param_count
,
ret_count
,
0
))
{
sprintf
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
no_action
--
;
...
@@ -820,7 +820,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
...
@@ -820,7 +820,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
lua_remove
(
current_state
,
-
2
);
lua_remove
(
current_state
,
-
2
);
push_param
(
current_state
);
push_param
(
current_state
);
if
(
lua_pcall
(
current_state
,
param_count
,
ret_count
,
0
))
{
if
(
lua_pcall
(
current_state
,
param_count
,
ret_count
,
0
))
{
sprintf
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
no_action
--
;
...
@@ -860,7 +860,7 @@ int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count,
...
@@ -860,7 +860,7 @@ int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count,
call_depth
++
;
call_depth
++
;
push_param
(
current_state
);
push_param
(
current_state
);
if
(
lua_pcall
(
current_state
,
param_count
,
ret_count
,
0
))
{
if
(
lua_pcall
(
current_state
,
param_count
,
ret_count
,
0
))
{
sprintf
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
no_action
--
;
...
@@ -917,7 +917,7 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
...
@@ -917,7 +917,7 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
for
(
int32
i
=
0
;
i
<
extraargs
;
++
i
)
for
(
int32
i
=
0
;
i
<
extraargs
;
++
i
)
lua_pushvalue
(
current_state
,
(
int32
)(
-
extraargs
-
2
));
lua_pushvalue
(
current_state
,
(
int32
)(
-
extraargs
-
2
));
if
(
lua_pcall
(
current_state
,
1
+
extraargs
,
1
,
0
))
{
if
(
lua_pcall
(
current_state
,
1
+
extraargs
,
1
,
0
))
{
sprintf
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
no_action
--
;
...
@@ -949,7 +949,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
...
@@ -949,7 +949,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
for
(
int32
i
=
0
;
i
<
extraargs
;
++
i
)
for
(
int32
i
=
0
;
i
<
extraargs
;
++
i
)
lua_pushvalue
(
current_state
,
(
int32
)(
-
extraargs
-
2
));
lua_pushvalue
(
current_state
,
(
int32
)(
-
extraargs
-
2
));
if
(
lua_pcall
(
current_state
,
1
+
extraargs
,
1
,
0
))
{
if
(
lua_pcall
(
current_state
,
1
+
extraargs
,
1
,
0
))
{
sprintf
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
lua_pop
(
current_state
,
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
no_action
--
;
...
@@ -1059,7 +1059,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
...
@@ -1059,7 +1059,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
return
COROUTINE_YIELD
;
return
COROUTINE_YIELD
;
}
else
{
}
else
{
coroutines
.
erase
(
f
);
coroutines
.
erase
(
f
);
sprintf
(
pduel
->
strbuffer
,
lua_tostring
(
rthread
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
rthread
,
-
1
));
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
lua_pop
(
rthread
,
1
);
lua_pop
(
rthread
,
1
);
current_state
=
lua_state
;
current_state
=
lua_state
;
...
...
interpreter.h
View file @
9e7c8ca8
...
@@ -73,6 +73,11 @@ public:
...
@@ -73,6 +73,11 @@ public:
static
int32
get_function_handle
(
lua_State
*
L
,
int32
index
);
static
int32
get_function_handle
(
lua_State
*
L
,
int32
index
);
static
void
set_duel_info
(
lua_State
*
L
,
duel
*
pduel
);
static
void
set_duel_info
(
lua_State
*
L
,
duel
*
pduel
);
static
duel
*
get_duel_info
(
lua_State
*
L
);
static
duel
*
get_duel_info
(
lua_State
*
L
);
template
<
size_t
N
>
static
char
*
strcpy
(
char
(
&
src
)[
N
],
const
char
*
dst
)
{
return
strncpy
(
reinterpret_cast
<
char
*>
(
&
src
),
dst
,
N
);
}
};
};
#define PARAM_TYPE_INT 0x01
#define PARAM_TYPE_INT 0x01
...
...
libdebug.cpp
View file @
9e7c8ca8
...
@@ -18,7 +18,7 @@ int32 scriptlib::debug_message(lua_State *L) {
...
@@ -18,7 +18,7 @@ int32 scriptlib::debug_message(lua_State *L) {
lua_getglobal
(
L
,
"tostring"
);
lua_getglobal
(
L
,
"tostring"
);
lua_pushvalue
(
L
,
-
2
);
lua_pushvalue
(
L
,
-
2
);
lua_pcall
(
L
,
1
,
1
,
0
);
lua_pcall
(
L
,
1
,
1
,
0
);
sprintf
(
pduel
->
strbuffer
,
"%s"
,
lua_tostring
(
L
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
L
,
-
1
));
handle_message
(
pduel
,
2
);
handle_message
(
pduel
,
2
);
return
0
;
return
0
;
}
}
...
...
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