flux-framework / flux-sched

Fluxion Graph-based Scheduler
GNU Lesser General Public License v3.0
89 stars 41 forks source link

planner/dfu: avoid dereferencing empty vector #1239

Closed trws closed 4 months ago

trws commented 4 months ago

problem: a few places were using &(vec[0]) to get an address of the start of a potentially empty vector. This is almost always actually safe in practice, but it's not allowed and technically could be treated like a null dereference as well.

solution: use the vec.data() method that exists specifically for this purpose

@milroy tagging you here since we happened to be talking about this code just the other day. As far as I know this hasn't been touched recently, but maybe the hardening flags in the buildfarm did. 🤷

jameshcorbett commented 4 months ago

maybe the hardening flags in the buildfarm did.

I certainly didn't change anything by hand but maybe something in the buildfarm changed? I don't know the buildfarm that well.

trws commented 4 months ago

We pull the hardening flags from the platform specfiles, so it could have been something we did, or even an update from RHEL. 🤷

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 74.1%. Comparing base (eca89f0) to head (686f0cc). Report is 168 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1239 +/- ## ======================================== - Coverage 74.1% 74.1% -0.1% ======================================== Files 103 103 Lines 14607 14606 -1 ======================================== - Hits 10829 10828 -1 Misses 3778 3778 ``` | [Files with missing lines](https://app.codecov.io/gh/flux-framework/flux-sched/pull/1239?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flux-framework) | Coverage Δ | | |---|---|---| | [resource/traversers/dfu.cpp](https://app.codecov.io/gh/flux-framework/flux-sched/pull/1239?src=pr&el=tree&filepath=resource%2Ftraversers%2Fdfu.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flux-framework#diff-cmVzb3VyY2UvdHJhdmVyc2Vycy9kZnUuY3Bw) | `86.1% <100.0%> (ø)` | | | [resource/traversers/dfu\_impl.cpp](https://app.codecov.io/gh/flux-framework/flux-sched/pull/1239?src=pr&el=tree&filepath=resource%2Ftraversers%2Fdfu_impl.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=flux-framework#diff-cmVzb3VyY2UvdHJhdmVyc2Vycy9kZnVfaW1wbC5jcHA=) | `85.0% <100.0%> (-0.1%)` | :arrow_down: |