undefect. CWE-407 — 92 sites, 42 ecosystems
B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections. Squash of 94 local commits onto remote master.
This commit is contained in:
parent
0a580b313d
commit
db29a08762
1311 changed files with 371202 additions and 1188 deletions
34
defects/octave/patch/octave-0001-vecdim-binary-search.patch
Normal file
34
defects/octave/patch/octave-0001-vecdim-binary-search.patch
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
diff --git a/libinterp/corefcn/data.cc b/libinterp/corefcn/data.cc
|
||||
index a1b2c3d..d4e5f6a 100644
|
||||
--- a/libinterp/corefcn/data.cc
|
||||
+++ b/libinterp/corefcn/data.cc
|
||||
@@ -133,9 +133,10 @@ parse_vecdim_arg (const octave_value &dimarg, const Array<octave_value> &arg,
|
||||
// Add remaining dims to permutation vector
|
||||
for (int i = 0; i < ndims; i++)
|
||||
{
|
||||
- if (std::find (vecdim.begin (), vecdim.end (), i)
|
||||
- == vecdim.end ())
|
||||
+ // CWE-407 fix: vecdim is already sorted (std::sort above);
|
||||
+ // std::find ignores the sort and is O(|vecdim|) per iteration.
|
||||
+ // std::binary_search is O(log |vecdim|).
|
||||
+ if (!std::binary_search (vecdim.begin (), vecdim.end (), i))
|
||||
{
|
||||
perm_vec(idx) = i;
|
||||
new_sz(idx) = sz(i);
|
||||
diff --git a/libinterp/corefcn/numeric/max.cc b/libinterp/corefcn/numeric/max.cc
|
||||
index b2c3d4e..e5f6a7b 100644
|
||||
--- a/libinterp/corefcn/numeric/max.cc
|
||||
+++ b/libinterp/corefcn/numeric/max.cc
|
||||
@@ -106,9 +106,10 @@ do_minmax_nd (const octave_value& arg, int dim, bool ismin,
|
||||
// Add remaining dims to permutation vector
|
||||
for (int i = 0; i < ndims; i++)
|
||||
{
|
||||
- if (std::find (vecdim.begin (), vecdim.end (), i)
|
||||
- == vecdim.end ())
|
||||
+ // CWE-407 fix: vecdim is already sorted (std::sort above);
|
||||
+ // std::find ignores the sort and is O(|vecdim|) per iteration.
|
||||
+ // std::binary_search is O(log |vecdim|).
|
||||
+ if (!std::binary_search (vecdim.begin (), vecdim.end (), i))
|
||||
{
|
||||
perm_vec(idx) = i;
|
||||
new_sz(idx) = sz(i);
|
||||
Loading…
Add table
Add a link
Reference in a new issue