mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-18 23:14:44 +01:00
fix: Add input validation and bounds checking to parsing methods (#990)
* fix: Resolved boundary condition issues in string processing Addressed null and length checks during string splitting across multiple model classes to prevent potential null pointer exceptions and array out-of-bounds errors * fix: Throw exceptions instead of silently returning when package manager output formats are invalid Modified the _pacman, _opkg, and _apk parsing methods to throw exceptions when input formats are invalid, rather than silently returning, to prevent potential error handling issues.
This commit is contained in:
@@ -166,6 +166,7 @@ class SingleCpuCore extends TimeSeqIface<SingleCpuCore> {
|
||||
final id = item.split(' ').firstOrNull;
|
||||
if (id == null) continue;
|
||||
final matches = item.replaceFirst(id, '').trim().split(' ');
|
||||
if (matches.length < 7) continue;
|
||||
cpus.add(
|
||||
SingleCpuCore(
|
||||
id,
|
||||
|
||||
@@ -97,8 +97,8 @@ class Proc {
|
||||
}
|
||||
|
||||
String get binary {
|
||||
final parts = command.split(' ');
|
||||
return parts[0];
|
||||
final parts = command.trim().split(' ').where((e) => e.isNotEmpty).toList();
|
||||
return parts.isNotEmpty ? parts[0] : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user