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

Incorrect handling of longtext MySQL fields #2236

Open
6 tasks done
antirix-dev opened this issue Dec 28, 2024 · 0 comments
Open
6 tasks done

Incorrect handling of longtext MySQL fields #2236

antirix-dev opened this issue Dec 28, 2024 · 0 comments

Comments

@antirix-dev
Copy link

antirix-dev commented Dec 28, 2024

Help us help you

  • I have checked that my issue doesn't exist yet.
  • I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • I can always reproduce the issue with the provided description below.

Environment

  • Operating System version:
  • Game/AppID (with version if applicable):
  • Current SourceMod version:
  • Current SourceMod snapshot:
  • Current Metamod: Source snapshot:

Description

Consider the following:

  1. A table contains a longtext field.
  2. A query retrieves a single row, including that field.
  3. SQL_FetchString is used to read the field into a buffer of a length smaller than the longtext maximum length, but larger than the actual data due to be retrieved
  4. This will result in an error

It appears that the code incorrectly bails upon determining that the buffer wouldn't be able to hold the maximum possible size of the longtext field - though that is irrelevant as it actually could hold the data in the scenario in question.

Problematic Code (or Steps to Reproduce)

Database db;
// ... code to connect to database
DBStatement stmt = SQL_PrepareQuery(db, "<sql here to select * from table with longtext field limit 1>", error, errorSize);
SQL_Execute(stmt);
SQL_FetchRow(stmt)
char buf[length larger than the actual data in the field];
SQL_FetchString(stmt, <field index>, buf, sizeof(buf));

Error: Exception reported: Could not fetch data in field <field index> as a string

Logs

  • Please attach in separate files: game output, library logs, kernel logs, and any other supporting information.
  • In case of a crash, please attach minidump or dump analyze output.
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

1 participant