[U-Boot] [U-Boot, 2/2] tpm: sandbox: fix wrong assignment with a simplification
Tom Rini
trini at konsulko.com
Mon Aug 13 23:57:55 UTC 2018
On Sun, Aug 05, 2018 at 06:53:07PM +0200, Miquel Raynal wrote:
> The recv variable in sandbox_tpm2_fill_buf() is a pointer on a pointer
> of a char array. It means accessing *recv is the char array pointer
> itself while **recv is the first character of that array. There is no
> need for such indirection here, so simplify the code.
>
> Simplifying things will make the last assignment right: "*recv = NULL"
> is now correct. The issue has been found by the following Coverity
> Scan report:
>
> CID 183371: Incorrect expression (UNUSED_VALUE)
> Assigning value "4UL" to "*recv" here, but that stored value is overwritten before it can be used.
> 232 *recv += sizeof(rc);
> 233
> 234 /* Add trailing \0 */
> 235 *recv = NULL;
>
> While at simplifying things, use '\0' instead of NULL when adding an
> empty char at the end of the buffer.
>
> Reported-by: Tom Rini <trini at konsulko.com>
> Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
> Reviewed-by: Simon Glass <sjg at chromium.org>
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/20180813/d180b540/attachment.sig>
More information about the U-Boot
mailing list