Even though it is not dereferenced, it is UB to take the address of an out of bounds array element.
Details
Details
- Reviewers
melifaro bz pouria des adrian - Group Reviewers
network - Commits
- rG90c11896412d: netlink: Avoid undefined behaviour
rG1a4ad649cb13: netlink: Avoid undefined behaviour
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
| sys/netlink/netlink_generic.c | ||
|---|---|---|
| 118 | I do not like initialization during declaration, especially if there is an early return before they are used (I am sure compilers optimize that but it makes reading harder as you keep state in your head). But given that's common in this code ... | |
| sys/netlink/netlink_generic.c | ||
|---|---|---|
| 131–136 | And no need for initialization at the beginning. | |
| sys/netlink/netlink_generic.c | ||
|---|---|---|
| 131–136 | +1 | |
| sys/netlink/netlink_generic.c | ||
|---|---|---|
| 131–137 | is how you'd write it to avoid code duplication if you really cared about that sort of thing, for what it's worth, but I'm not convinced the obfuscation is worth it, it's not a complicated expression to duplicate. Also the same pattern is present below for cmd (though it and ghdr are not declared at the block's start like they should be...). | |