Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sqlite crashes when strlen(file) === 1 #78

Open
Swift-Strider opened this issue Feb 12, 2022 · 4 comments
Open

Sqlite crashes when strlen(file) === 1 #78

Swift-Strider opened this issue Feb 12, 2022 · 4 comments

Comments

@Swift-Strider
Copy link

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"

@SOF3
Copy link
Member

SOF3 commented Feb 13, 2022

Why would you create single character files to start with?

@Swift-Strider
Copy link
Author

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.

@ghost
Copy link

ghost commented Feb 13, 2022

Why would you create single character files to start with?

because less characters = more performance kekw

@SOF3
Copy link
Member

SOF3 commented Feb 13, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants