Daniel Axtens 2f533a89a8 commands/menuentry: Fix quoting in setparams_prefix()
Commit 9acdcbf32542 (use single quotes in menuentry setparams command)
says that expressing a quoted single quote will require 3 characters. It
actually requires (and always did require!) 4 characters:

  str: a'b => a'\''b
  len:  3  => 6 (2 for the letters + 4 for the quote)

This leads to not allocating enough memory and thus out of bounds writes
that have been observed to cause heap corruption.

Allocate 4 bytes for each single quote.

Commit 22e7dbb2bb81 (Fix quoting in legacy parser.) does the same
quoting, but it adds 3 as extra overhead on top of the single byte that
the quote already needs. So it's correct.

Fixes: 9acdcbf32542 (use single quotes in menuentry setparams command)
Fixes: CVE-2021-20233

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2021-03-02 15:54:17 +01:00
..
2013-12-21 03:03:31 +01:00
2021-03-02 15:54:15 +01:00
2019-02-25 14:02:05 +01:00
2015-01-24 20:52:02 +01:00
2021-03-02 15:54:17 +01:00
2015-12-15 10:25:34 +03:00
2020-07-29 16:55:47 +02:00
2019-04-09 10:03:29 +10:00
2020-07-29 16:55:47 +02:00
2019-04-09 10:03:29 +10:00
2012-02-12 15:25:25 +01:00