libasynql
libasynql copied to clipboard
Sqlite crashes when `strlen(file) === 1`
Describe the bug
Only on Windows, the libasynql::create
function crashes with the following config
type: "sqlite"
sqlite:
file: "a" #NOTICE: `file` is a single character
with this error
ErrorException: "Uninitialized string offset 1" (EXCEPTION) in "C:/<pocketmine-dir>/virions/libasynql_dev-174.phar/src/poggit/libasynql/libasynql" at line 162
libasynql.php The comment marks the ErrorException.
private static function resolvePath(string $folder, string $path) : string{
if($path[0] === "/"){
return $path;
}
if(Utils::getOS() === "win"){
if($path[0] === "\\" || $path[1] === ":"){
// ErrorException thrown Above! ^^^^^^^
return $path;
}
}
return $folder . $path;
}
Another Bug
Furthermore, having file: ""
throws an error on all platforms, but that config is invalid anyways. It's arguable if that should be fixed too.
Expected behavior This should not crash.
Environment OS: "win" PocketMine version: "4.2.0"
Why would you create single character files to start with?
Why would you create single character files to start with?
I know, it's pretty strange to have your file named like that. But to me, this issue is still valid.
Why would you create single character files to start with?
because less characters = more performance kekw
Why would you create single character files to start with?
because less characters = more performance kekw
Definitely. We need a plugin that bans players with more than 5 characters in their name.