Skip to content

Conversation

@pabigot
Copy link
Contributor

@pabigot pabigot commented Jan 27, 2021

An assignment from one multi-word union field to another was not safe
from corruption. Copy the value out to a local value before storing it
to the preferred union field.

Fixes #31646

@pabigot pabigot added the Coverity A Coverity detected issue or its fix label Jan 27, 2021
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this needs to be in a { } block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@galak It's only used within this case statement. I'd rather limit its scope, instead of making it visible throughout the entire switch body.

If you don't like that, I could move it up to the top of the enclosing while loop but that's a pretty wide scope too.

What do you want me to do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enclose the entire switch block in braces if you need to declare variables, or declare them toplevel, anything but this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De gustibus non est disputandum. Done.

An assignment from one multi-word union field to another was not safe
from corruption.  Copy the value out to a local value before storing it
to the preferred union field.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
@nashif nashif merged commit 10180af into zephyrproject-rtos:master Jan 27, 2021
@pabigot pabigot deleted the nordic/20210127b branch January 28, 2021 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Coverity A Coverity detected issue or its fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Coverity CID :215712] Assignment of overlapping memory in lib/os/cbprintf_complete.c

4 participants