Skip to content

Commit becf445

Browse files
abnegateclaude
andcommitted
Add lower-bound validation for VARCHAR size in MariaDB adapter
Throws DatabaseException when VARCHAR size is <= 0, ensuring both lower and upper bounds are validated before returning the VARCHAR type. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 428be5e commit becf445

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Database/Adapter/MariaDB.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,9 @@ protected function getSQLType(string $type, int $size, bool $signed = true, bool
16791679
return "VARCHAR({$size})";
16801680

16811681
case Database::VAR_VARCHAR:
1682+
if ($size <= 0) {
1683+
throw new DatabaseException('VARCHAR size ' . $size . ' is invalid; must be > 0. Use TEXT, MEDIUMTEXT, or LONGTEXT instead.');
1684+
}
16821685
if ($size > $this->getMaxVarcharLength()) {
16831686
throw new DatabaseException('VARCHAR size ' . $size . ' exceeds maximum varchar length ' . $this->getMaxVarcharLength() . '. Use TEXT, MEDIUMTEXT, or LONGTEXT instead.');
16841687
}

0 commit comments

Comments
 (0)