efi: cper: fix scnprintf() use in cper_mem_err_location()
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Wed, 21 Apr 2021 19:31:46 +0000 (21:31 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Fri, 27 Aug 2021 14:01:27 +0000 (16:01 +0200)
commit5eff88dd6b4badd664d7d3b648103d540b390248
treebb18c568b0ef5a82333fd21eace9655ff60ee668
parente73f0f0ee7541171d89f2e2491130c7771ba58d3
efi: cper: fix scnprintf() use in cper_mem_err_location()

The last two if-clauses fail to update n, so whatever they might have
written at &msg[n] would be cut off by the final nul-termination.

That nul-termination is redundant; scnprintf(), just like snprintf(),
guarantees a nul-terminated output buffer, provided the buffer size is
positive.

And there's no need to discount one byte from the initial buffer;
vsnprintf() expects to be given the full buffer size - it's not going
to write the nul-terminator one beyond the given (buffer, size) pair.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/cper.c