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

METHOD_ADD and ADD_METHOD_TO do not consider unsigned types #2059

Open
Mis1eader-dev opened this issue Jun 9, 2024 · 1 comment
Open

METHOD_ADD and ADD_METHOD_TO do not consider unsigned types #2059

Mis1eader-dev opened this issue Jun 9, 2024 · 1 comment

Comments

@Mis1eader-dev
Copy link
Member

Describe the bug
Creating an HttpController with methods that take in uint64_t for example, and making a request to -1 will underflow and become UINT64_MAX.
Another related bug is if the URL contains characters, it still processes it.

Expected behavior
Should give 400 Bad Request upon error.

Desktop (please complete the following information):

  • OS: Ubuntu

Additional context
For the time being the only choice is to take by string and do validation manually.

@Mis1eader-dev
Copy link
Member Author

In case this issue gets tackled, there is std::from_chars for ASCII to primitive number type conversion, which resides in the <charconv> header.

A proper checker would look like this:

string_view param = "123d";
uint64_t num;
if(std::from_chars(param.begin(), param.end(), num).ptr != param.end())
    return error;

// success, do something with [num]

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