diff options
| author | Kay Potthoff <[email protected]> | 2018-07-17 08:19:39 +0200 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2018-07-24 09:25:23 -0400 |
| commit | 149c21b098dafc5a2ae619555a844e8d0a9523f6 (patch) | |
| tree | fd593e065804edfe31d57678b19823cfccd4880f /cmd | |
| parent | 4807c40c2f145e9721fc7891730cb26043cbd723 (diff) | |
mtdparts: fixed buffer overflow bug
In the case that there was no name defined for a partition the
code assumes that name_len is 22 and therefore allocates exactly
that space for a dummy name. But the function sprintf() first
resolves "0x%08llx@0x%08llx" to a string that is longer than 22
bytes. This leads to a buffer overflow. The replacement function
snprintf() limits the copied bytes to name_len and therefore
avoids the buffer overflow.
Signed-off-by: Kay Potthoff <[email protected]>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/mtdparts.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c index c4010091338..0da3afd75ff 100644 --- a/cmd/mtdparts.c +++ b/cmd/mtdparts.c @@ -690,7 +690,7 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i part->auto_name = 0; } else { /* auto generated name in form of size@offset */ - sprintf(part->name, "0x%08llx@0x%08llx", size, offset); + snprintf(part->name, name_len, "0x%08llx@0x%08llx", size, offset); part->auto_name = 1; } |
