* [U-Boot] [PATCH 1/1] fw_printenv: Fix crash due to incorrect size for malloc'ed string.
@ 2018-04-04 8:09 Kristian Amlie
2018-04-11 14:05 ` [U-Boot] [U-Boot, " Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Kristian Amlie @ 2018-04-04 8:09 UTC (permalink / raw)
To: u-boot
Using sizeof gives the size of the pointer only, not the string. This
could easily lead to crashes when using -l argument.
Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
---
tools/env/fw_env_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index d93a915..fb4afa5 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
argv += optind;
if (env_opts.lockname) {
- lockname = malloc(sizeof(env_opts.lockname) +
+ lockname = malloc(strlen(env_opts.lockname) +
sizeof(CMD_PRINTENV) + 10);
if (!lockname) {
fprintf(stderr, "Unable allocate memory");
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [U-Boot, 1/1] fw_printenv: Fix crash due to incorrect size for malloc'ed string.
2018-04-04 8:09 [U-Boot] [PATCH 1/1] fw_printenv: Fix crash due to incorrect size for malloc'ed string Kristian Amlie
@ 2018-04-11 14:05 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2018-04-11 14:05 UTC (permalink / raw)
To: u-boot
On Wed, Apr 04, 2018 at 10:09:57AM +0200, Kristian Amlie wrote:
> Using sizeof gives the size of the pointer only, not the string. This
> could easily lead to crashes when using -l argument.
>
> Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180411/ea5f9877/attachment.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-11 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04 8:09 [U-Boot] [PATCH 1/1] fw_printenv: Fix crash due to incorrect size for malloc'ed string Kristian Amlie
2018-04-11 14:05 ` [U-Boot] [U-Boot, " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.