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:
@@ -62,6 +62,7 @@ class UpgradePkgInfo {
|
||||
|
||||
void _parsePacman(String raw) {
|
||||
final parts = raw.split(' ');
|
||||
if (parts.length < 4) throw Exception('Invalid pacman output format');
|
||||
package = parts[0];
|
||||
nowVersion = parts[1];
|
||||
newVersion = parts[3];
|
||||
@@ -70,6 +71,7 @@ class UpgradePkgInfo {
|
||||
|
||||
void _parseOpkg(String raw) {
|
||||
final parts = raw.split(' - ');
|
||||
if (parts.length < 3) throw Exception('Invalid opkg output format');
|
||||
package = parts[0];
|
||||
nowVersion = parts[1];
|
||||
newVersion = parts[2];
|
||||
@@ -80,6 +82,7 @@ class UpgradePkgInfo {
|
||||
void _parseApk(String raw) {
|
||||
final parts = raw.split(' ');
|
||||
final len = parts.length;
|
||||
if (len < 2) throw Exception('Invalid apk output format');
|
||||
newVersion = parts[len - 1];
|
||||
nowVersion = parts[0];
|
||||
newVersion = newVersion.substring(0, newVersion.length - 1);
|
||||
|
||||
Reference in New Issue
Block a user