Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tapasco
tapasco
Commits
0fa7cbba
Commit
0fa7cbba
authored
May 21, 2019
by
Jaco Hofmann
Browse files
Fix dangerous strncpy, closes
#61
parent
cfdba059
Pipeline
#1252
passed with stages
in 128 minutes and 48 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
platform/common/src/platform_ctx.c
View file @
0fa7cbba
...
...
@@ -19,14 +19,14 @@ struct platform_ctx {
};
static
int
get_tlkm_version
(
platform_ctx_t
*
ctx
,
char
*
v
)
int
get_tlkm_version
(
platform_ctx_t
*
ctx
,
char
*
v
,
int
v_buffer_length
)
{
struct
tlkm_ioctl_version_cmd
c
=
{
.
version
=
""
,
};
if
(
ioctl
(
ctx
->
fd_tlkm
,
TLKM_IOCTL_VERSION
,
&
c
))
{
ERR
(
"getting version from device driver failed: %s (%d)"
,
strerror
(
errno
),
errno
);
return
errno
;
}
strncpy
(
v
,
c
.
version
,
strlen
(
c
.
version
)
+
1
);
strncpy
(
v
,
c
.
version
,
v_buffer_length
);
return
0
;
}
...
...
@@ -71,7 +71,7 @@ platform_res_t init_platform(platform_ctx_t *ctx)
r
=
PERR_TLKM_ERROR
;
goto
err_tlkm
;
}
if
(
get_tlkm_version
(
ctx
,
ctx
->
version
))
goto
err_ioctl
;
if
(
get_tlkm_version
(
ctx
,
ctx
->
version
,
TLKM_VERSION_SZ
))
goto
err_ioctl
;
LOG
(
LPLL_TLKM
,
"TLKM version: %s"
,
ctx
->
version
);
if
(
enum_devs
(
ctx
))
goto
err_ioctl
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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