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

Check more user-supplied strings used as SQL identifier #1758

Merged

Conversation

lonvia
Copy link
Collaborator

@lonvia lonvia commented Sep 8, 2022

We already consistently quote all identifier used in SQL strings in the code to avoid SQL injection issues. The quoting works on the assumption that there are no double quotes in the string itself. The flex output already checked all user-supplied strings for conformance.

This PR adds the same check to the prefix and schema command-line parameters which are used as SQL identifiers and for the column names and types from the pgsql style file.

There are a couple of other places outside the flex output where
we should check that psql identifiers are correctly quotable.
Adds checks for the prefix and schema commandline parameters
and for column names and types from the pgsql style file.
src/pgsql.cpp Outdated

throw std::runtime_error{
"Special characters are not allowed in {} names: '{}'."_format(in,
name)};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message can now be confusing, for instance for the --prefix option it will say:
Special characters are not allowed in prefix names: '...'. . Maybe just remove the names?

Copy link
Collaborator

@joto joto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gute Lösung

@lonvia lonvia merged commit 0899d68 into osm2pgsql-dev:master Sep 11, 2022
@lonvia lonvia deleted the check-for-invalid-prefix-and-schema-names branch September 11, 2022 08:28
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

Successfully merging this pull request may close these issues.

None yet

2 participants