Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
7c39f6f7
Unverified
Commit
7c39f6f7
authored
Oct 10, 2018
by
Soby Mathew
Committed by
GitHub
Oct 10, 2018
Browse files
Merge pull request #1489 from teknoraver/master
doimage: get rid of non null terminated strings by strncpy
parents
c6d1fe95
fd10a0a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/doimage/doimage.c
View file @
7c39f6f7
...
@@ -216,7 +216,7 @@ void usage(void)
...
@@ -216,7 +216,7 @@ void usage(void)
}
}
/* globals */
/* globals */
options_t
opts
=
{
static
options_t
opts
=
{
.
bin_ext_file
=
"NA"
,
.
bin_ext_file
=
"NA"
,
.
sec_cfg_file
=
"NA"
,
.
sec_cfg_file
=
"NA"
,
.
sec_opts
=
0
,
.
sec_opts
=
0
,
...
@@ -1578,9 +1578,9 @@ error:
...
@@ -1578,9 +1578,9 @@ error:
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
char
in_file
[
MAX_FILENAME
+
1
];
char
in_file
[
MAX_FILENAME
+
1
]
=
{
0
}
;
char
out_file
[
MAX_FILENAME
+
1
];
char
out_file
[
MAX_FILENAME
+
1
]
=
{
0
}
;
char
ext_file
[
MAX_FILENAME
+
1
];
char
ext_file
[
MAX_FILENAME
+
1
]
=
{
0
}
;
FILE
*
in_fd
=
NULL
;
FILE
*
in_fd
=
NULL
;
FILE
*
out_fd
=
NULL
;
FILE
*
out_fd
=
NULL
;
int
parse
=
0
;
int
parse
=
0
;
...
@@ -1590,6 +1590,7 @@ int main(int argc, char *argv[])
...
@@ -1590,6 +1590,7 @@ int main(int argc, char *argv[])
int
image_size
;
int
image_size
;
uint8_t
*
image_buf
=
NULL
;
uint8_t
*
image_buf
=
NULL
;
int
read
;
int
read
;
size_t
len
;
uint32_t
nand_block_size_kb
,
mlc_nand
;
uint32_t
nand_block_size_kb
,
mlc_nand
;
/* Create temporary file for building extensions
/* Create temporary file for building extensions
...
@@ -1660,13 +1661,19 @@ int main(int argc, char *argv[])
...
@@ -1660,13 +1661,19 @@ int main(int argc, char *argv[])
if
(
optind
>=
argc
)
if
(
optind
>=
argc
)
usage_err
(
"missing input file name"
);
usage_err
(
"missing input file name"
);
strncpy
(
in_file
,
argv
[
optind
],
MAX_FILENAME
);
len
=
strlen
(
argv
[
optind
]);
if
(
len
>
MAX_FILENAME
)
usage_err
(
"file name too long"
);
memcpy
(
in_file
,
argv
[
optind
],
len
);
optind
++
;
optind
++
;
/* Output file must exist in non parse mode */
/* Output file must exist in non parse mode */
if
(
optind
<
argc
)
if
(
optind
<
argc
)
{
strncpy
(
out_file
,
argv
[
optind
],
MAX_FILENAME
);
len
=
strlen
(
argv
[
optind
]);
else
if
(
!
parse
)
if
(
len
>
MAX_FILENAME
)
usage_err
(
"file name too long"
);
memcpy
(
out_file
,
argv
[
optind
],
len
);
}
else
if
(
!
parse
)
usage_err
(
"missing output file name"
);
usage_err
(
"missing output file name"
);
/* open the input file */
/* open the input file */
...
...
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