platform/x86: hp-bioscfg: prevent a small buffer overflow
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 18 Jul 2023 07:05:34 +0000 (10:05 +0300)
committerHans de Goede <hdegoede@redhat.com>
Wed, 26 Jul 2023 14:16:22 +0000 (16:16 +0200)
commitb3a8692d2c6632ddaa41ca61544b632c49e75efc
tree3b5e03bee497ecd9c2215e49c0d72b65b898027d
parent93d99fd8e605c09ae8521a19c2b08b57b8cc4165
platform/x86: hp-bioscfg: prevent a small buffer overflow

This function escapes certain special characters like \n.  So if the
last character in the string is a '\n' then it gets changed into two
characters '\' and '\n'.  But maybe we only have space for the '\' so
we need to check for that.

The "conv_dst_size" variable is always less than or to equal the "size"
variable.  It's easier to just check "conv_dst_size" instead of checking
both.

Fixes: a34fc329b189 ("platform/x86: hp-bioscfg: bioscfg")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/b4950310-e65f-412f-8d2b-90bb074a6572@moroto.mountain
Reviewed-by: Jorge Lopez <jorge.lopez2@hp.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c