diff options
| author | Pjotr <wrk@bosa.lan> | 2026-10-03 13:58:04 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-10-03 13:58:04 +0000 |
| commit | c7c89dbb9776a6566d6c6c017951a54114e2c214 (patch) | |
| tree | 7bb961bb6c748b2749feb068b14032bb98a61c5c /sourcecodes/runtime_check.php | |
| parent | f9d5c4116711d6fd82f2a8cf55acc10bf36ab740 (diff) | |
| download | gn-bnw-c7c89dbb9776a6566d6c6c017951a54114e2c214.tar.gz | |
validate the GN2 payload before prep; informative failures throughout
Found by an exhaustive small-payload fuzz (test/fuzz_bnw.py):
- bn_genenet.php: fail fast with a plain-English problem list for
header-only payloads, ragged rows, single variable/sample, all-NA
columns and all-NA rows, non-numeric cells and empty payloads;
normalize CRLF and squeeze redundant row separators; rename
duplicate variable names with a note (prep used to crash on each
of these deep inside octave)
- runtime_check.php: exe_time no longer fatals ("int + string") when
prep did not produce its tables; falls back to a default estimate
- execute_bn_gom.php: the FAILED page gains plain-English hints for
the recurring octave failure modes
- test/bnw_http_tests.py: tests t22-t33 lock the behaviour in
- test/fuzz_bnw.py: the parameter-space fuzzer (75 cases)
Diffstat (limited to 'sourcecodes/runtime_check.php')
| -rw-r--r-- | sourcecodes/runtime_check.php | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/sourcecodes/runtime_check.php b/sourcecodes/runtime_check.php index 39950ea3..60d02434 100644 --- a/sourcecodes/runtime_check.php +++ b/sourcecodes/runtime_check.php @@ -22,39 +22,42 @@ if($parent_number>$node) $paent="maxparent_table.txt"; -$max_parent=file_get_contents("$paent"); +$max_parent=@file_get_contents("$paent"); $max_parent_row=array(); -$max_parent_row=explode("\n",$max_parent); - -$max_parent_data=array(); -$max_parent_data=explode("\t",$max_parent_row[$node]); -$local=$max_parent_data[$parent_number]; +$max_parent_row=explode("\n","$max_parent"); + +// The tables above only exist once prep has run for this data set; +// when prep failed (or has not run yet) the lookups below would hit +// missing rows and fatal with "Unsupported operand types: int + +// string". Fall back to conservative defaults instead. +$local=10; +if($node >= 0 && isset($max_parent_row[$node]) && $max_parent_row[$node] !== "") +{ + $max_parent_data=explode("\t","$max_parent_row[$node]"); + if(isset($max_parent_data[$parent_number]) && is_numeric($max_parent_data[$parent_number])) + $local=(float)$max_parent_data[$parent_number]; +} $k_n="k_only_table.txt"; -$k_p=file_get_contents("$k_n"); +$k_p=@file_get_contents("$k_n"); $k_row=array(); -$k_row=explode("\n",$k_p); +$k_row=explode("\n","$k_p"); +$k_time=10; +if($node >= 0 && isset($k_row[$node]) && $k_row[$node] !== "") +{ $k_data=array(); -$k_data=explode("\t",$k_row[$node]); -if($k_number==1) - $k_time=$k_data[0]; -else if($k_number==10) - $k_time=$k_data[1]; -else if($k_number==50) - $k_time=$k_data[2]; -else if($k_number==100) - $k_time=$k_data[3]; -else if($k_number==500) - $k_time=$k_data[4]; -else if($k_number==1000) - $k_time=$k_data[5]; -else if($k_number>1000) - $k_time=$k_data[5]*($k_number/1000); +$k_data=explode("\t","$k_row[$node]"); +$idx = ($k_number==1?0:($k_number==10?1:($k_number==50?2:($k_number==100?3:5)))); +if(isset($k_data[$idx]) && is_numeric($k_data[$idx])) + $k_time=(float)$k_data[$idx]; +if($k_number>1000 && isset($k_data[5]) && is_numeric($k_data[5])) + $k_time=(float)$k_data[5]*($k_number/1000); +} $totaltime=$local*($nrows/100)+$k_time+12; |
