undf: assign 898-906; stamp dosbox-x/rpcs3/ppsspp patches
This commit is contained in:
parent
50c1301928
commit
53ce6d7ab6
17 changed files with 210 additions and 1 deletions
|
|
@ -895,5 +895,14 @@
|
|||
"proton-0002": "UNDF-2026-000000894",
|
||||
"forgejo-0001-0001": "UNDF-2026-000000895",
|
||||
"snort3-0001-0001": "UNDF-2026-000000896",
|
||||
"tryton-0001-0001": "UNDF-2026-000000897"
|
||||
"tryton-0001-0001": "UNDF-2026-000000897",
|
||||
"dosbox-x-0001": "UNDF-2026-000000898",
|
||||
"dosbox-x-0002": "UNDF-2026-000000899",
|
||||
"openfoam-0001-0001": "UNDF-2026-000000900",
|
||||
"ppsspp-0001": "UNDF-2026-000000901",
|
||||
"ppsspp-0002": "UNDF-2026-000000902",
|
||||
"ppsspp-0003": "UNDF-2026-000000903",
|
||||
"rpcs3-0001": "UNDF-2026-000000904",
|
||||
"rpcs3-0002": "UNDF-2026-000000905",
|
||||
"rpcs3-0003": "UNDF-2026-000000906"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# UNDF: UNDF-2026-000000898
|
||||
--- a/src/dos/drives.h
|
||||
+++ b/src/dos/drives.h
|
||||
@@ -1350 +1350 @@
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# UNDF: UNDF-2026-000000899
|
||||
--- a/src/dos/drives.h
|
||||
+++ b/src/dos/drives.h
|
||||
@@ -1331 +1331 @@
|
||||
|
|
|
|||
BIN
defects/dosbox-x/test/DosboxXOverlayCacheTest.class
Normal file
BIN
defects/dosbox-x/test/DosboxXOverlayCacheTest.class
Normal file
Binary file not shown.
82
defects/openfoam-0001/patch/openfoam-0001.patch
Normal file
82
defects/openfoam-0001/patch/openfoam-0001.patch
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# UNDF: UNDF-2026-000000900
|
||||
--- a/src/lagrangian/molecularDynamics/moleculeCloud/moleculeCloud.C
|
||||
+++ b/src/lagrangian/molecularDynamics/moleculeCloud/moleculeCloud.C
|
||||
@@ -274,7 +274,9 @@
|
||||
|
||||
{
|
||||
- DynamicList<molecule*> molsToDelete;
|
||||
+ // CWE-407: molsToDelete was a DynamicList scanned by findIndex() O(N)
|
||||
+ // for each molecule pair, yielding O(pairs * D) where D = deletions.
|
||||
+ // Fix: use HashSet<molecule*> for O(1) membership checks.
|
||||
+ HashSet<molecule*> molsToDeleteSet;
|
||||
|
||||
const labelListList& dil(il_.dil());
|
||||
|
||||
@@ -304,13 +306,13 @@
|
||||
|| findIndex(pot_.removalOrder(), idJ)
|
||||
< findIndex(pot_.removalOrder(), idI)
|
||||
)
|
||||
{
|
||||
- if (findIndex(molsToDelete, molJ) == -1)
|
||||
+ if (!molsToDeleteSet.found(molJ))
|
||||
{
|
||||
- molsToDelete.append(molJ);
|
||||
+ molsToDeleteSet.insert(molJ);
|
||||
}
|
||||
}
|
||||
- else if (findIndex(molsToDelete, molI) == -1)
|
||||
+ else if (!molsToDeleteSet.found(molI))
|
||||
{
|
||||
- molsToDelete.append(molI);
|
||||
+ molsToDeleteSet.insert(molI);
|
||||
}
|
||||
}
|
||||
@@ -336,13 +338,13 @@
|
||||
|| findIndex(pot_.removalOrder(), idJ)
|
||||
< findIndex(pot_.removalOrder(), idI)
|
||||
)
|
||||
{
|
||||
- if (findIndex(molsToDelete, molJ) == -1)
|
||||
+ if (!molsToDeleteSet.found(molJ))
|
||||
{
|
||||
- molsToDelete.append(molJ);
|
||||
+ molsToDeleteSet.insert(molJ);
|
||||
}
|
||||
}
|
||||
- else if (findIndex(molsToDelete, molI) == -1)
|
||||
+ else if (!molsToDeleteSet.found(molI))
|
||||
{
|
||||
- molsToDelete.append(molI);
|
||||
+ molsToDeleteSet.insert(molI);
|
||||
}
|
||||
}
|
||||
@@ -353,10 +355,10 @@
|
||||
|
||||
- forAll(molsToDelete, mTD)
|
||||
+ forAllConstIter(HashSet<molecule*>, molsToDeleteSet, iter)
|
||||
{
|
||||
- deleteParticle(*(molsToDelete[mTD]));
|
||||
+ deleteParticle(*iter.key());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,9 +421,9 @@
|
||||
{
|
||||
- if (findIndex(molsToDelete, molI) == -1)
|
||||
+ if (!molsToDeleteSet.found(molI))
|
||||
{
|
||||
- molsToDelete.append(molI);
|
||||
+ molsToDeleteSet.insert(molI);
|
||||
}
|
||||
}
|
||||
else if
|
||||
@@ -437,9 +439,9 @@
|
||||
if (molI->origId() > molJ->origId())
|
||||
{
|
||||
- if (findIndex(molsToDelete, molI) == -1)
|
||||
+ if (!molsToDeleteSet.found(molI))
|
||||
{
|
||||
- molsToDelete.append(molI);
|
||||
+ molsToDeleteSet.insert(molI);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
BIN
defects/openfoam-0001/test/OpenFOAMMolsToDeleteDedupTest.class
Normal file
BIN
defects/openfoam-0001/test/OpenFOAMMolsToDeleteDedupTest.class
Normal file
Binary file not shown.
110
defects/openfoam-0001/test/OpenFOAMMolsToDeleteDedupTest.java
Normal file
110
defects/openfoam-0001/test/OpenFOAMMolsToDeleteDedupTest.java
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* CWE-407 unit test for OpenFOAM moleculeCloud.C molsToDelete dedup defect.
|
||||
*
|
||||
* Defect: moleculeCloud::removeHighEnergyOverlaps() uses
|
||||
* DynamicList<molecule*> molsToDelete with findIndex() O(N) membership
|
||||
* check inside a nested molecule-pair loop, yielding O(pairs * D)
|
||||
* complexity where D = number of deletions.
|
||||
*
|
||||
* Fix: Replace DynamicList + findIndex with HashSet for O(1) membership.
|
||||
*
|
||||
* This test models the defect pattern in Java:
|
||||
* - Defective: ArrayList + contains() for dedup in nested loop
|
||||
* - Fixed: HashSet for O(1) dedup
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
public class OpenFOAMMolsToDeleteDedupTest {
|
||||
|
||||
/** Simulate molecule with an id and origId */
|
||||
static class Molecule {
|
||||
final int id;
|
||||
final int origId;
|
||||
Molecule(int id, int origId) { this.id = id; this.origId = origId; }
|
||||
@Override public int hashCode() { return origId; }
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof Molecule && ((Molecule) o).origId == this.origId;
|
||||
}
|
||||
}
|
||||
|
||||
/** Defective: ArrayList + contains() O(N) per check => O(pairs * D) */
|
||||
static int defective(List<Molecule> cellI, List<Molecule> cellJ,
|
||||
List<Integer> removalOrder) {
|
||||
List<Molecule> molsToDelete = new ArrayList<>();
|
||||
long ops = 0;
|
||||
for (Molecule molI : cellI) {
|
||||
for (Molecule molJ : cellJ) {
|
||||
ops++;
|
||||
int idxI = removalOrder.indexOf(molI.id);
|
||||
int idxJ = removalOrder.indexOf(molJ.id);
|
||||
if (molI.id == molJ.id || idxJ < idxI) {
|
||||
// findIndex(molsToDelete, molJ) == -1
|
||||
ops += molsToDelete.size();
|
||||
if (!molsToDelete.contains(molJ)) {
|
||||
molsToDelete.add(molJ);
|
||||
}
|
||||
} else {
|
||||
ops += molsToDelete.size();
|
||||
if (!molsToDelete.contains(molI)) {
|
||||
molsToDelete.add(molI);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (int) ops;
|
||||
}
|
||||
|
||||
/** Fixed: HashSet for O(1) membership => O(pairs) */
|
||||
static int fixed(List<Molecule> cellI, List<Molecule> cellJ,
|
||||
List<Integer> removalOrder) {
|
||||
Set<Molecule> molsToDeleteSet = new HashSet<>();
|
||||
long ops = 0;
|
||||
for (Molecule molI : cellI) {
|
||||
for (Molecule molJ : cellJ) {
|
||||
ops++;
|
||||
int idxI = removalOrder.indexOf(molI.id);
|
||||
int idxJ = removalOrder.indexOf(molJ.id);
|
||||
if (molI.id == molJ.id || idxJ < idxI) {
|
||||
ops++; // O(1) HashSet lookup
|
||||
molsToDeleteSet.add(molJ);
|
||||
} else {
|
||||
ops++;
|
||||
molsToDeleteSet.add(molI);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (int) ops;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Simulate: 500 molecules in each cell, 3 molecule types
|
||||
int N = 500;
|
||||
List<Integer> removalOrder = Arrays.asList(0, 1, 2);
|
||||
Random rng = new Random(42);
|
||||
|
||||
List<Molecule> cellI = new ArrayList<>();
|
||||
List<Molecule> cellJ = new ArrayList<>();
|
||||
for (int i = 0; i < N; i++) {
|
||||
cellI.add(new Molecule(rng.nextInt(3), i));
|
||||
cellJ.add(new Molecule(rng.nextInt(3), N + i));
|
||||
}
|
||||
|
||||
int defOps = defective(cellI, cellJ, removalOrder);
|
||||
int fixOps = fixed(cellI, cellJ, removalOrder);
|
||||
|
||||
double ratio = (double) defOps / fixOps;
|
||||
|
||||
System.out.println("=== OpenFOAM moleculeCloud molsToDelete Dedup Test ===");
|
||||
System.out.println("Molecules per cell: " + N);
|
||||
System.out.println("Defective ops: " + defOps);
|
||||
System.out.println("Fixed ops: " + fixOps);
|
||||
System.out.printf("Ratio (defective/fixed): %.1fx%n", ratio);
|
||||
|
||||
// Verify: defective should be significantly more expensive
|
||||
boolean pass = ratio >= 5.0;
|
||||
System.out.println("RESULT: " + (pass ? "PASS" : "FAIL")
|
||||
+ " (ratio >= 5.0 required)");
|
||||
|
||||
if (!pass) System.exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
# UNDF: UNDF-2026-000000901
|
||||
--- a/Core/HLE/sceKernelThread.cpp
|
||||
+++ b/Core/HLE/sceKernelThread.cpp
|
||||
@@ -2544 +2544 @@
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# UNDF: UNDF-2026-000000902
|
||||
--- a/Core/HLE/sceKernelSemaphore.cpp
|
||||
+++ b/Core/HLE/sceKernelSemaphore.cpp
|
||||
@@ -370 +370 @@
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# UNDF: UNDF-2026-000000903
|
||||
--- a/Core/MIPS/IR/IRJit.cpp
|
||||
+++ b/Core/MIPS/IR/IRJit.cpp
|
||||
@@ -363,4 +363,5 @@
|
||||
|
|
|
|||
BIN
defects/ppsspp/test/PpssppKernelDedup.class
Normal file
BIN
defects/ppsspp/test/PpssppKernelDedup.class
Normal file
Binary file not shown.
|
|
@ -1,3 +1,4 @@
|
|||
# UNDF: UNDF-2026-000000904
|
||||
--- a/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp
|
||||
+++ b/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp
|
||||
@@ -2899,4 +2899,5 @@
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# UNDF: UNDF-2026-000000905
|
||||
--- a/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp
|
||||
+++ b/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp
|
||||
@@ -4842,4 +4842,5 @@
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# UNDF: UNDF-2026-000000906
|
||||
--- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp
|
||||
+++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp
|
||||
@@ -1553,8 +1553,11 @@
|
||||
|
|
|
|||
BIN
defects/rpcs3/test/Rpcs3SpuRecompilerTest.class
Normal file
BIN
defects/rpcs3/test/Rpcs3SpuRecompilerTest.class
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue