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

Miscellaneous bug fixes and improvements #2679

Merged
merged 8 commits into from May 14, 2024
Merged

Conversation

cgzones
Copy link
Contributor

@cgzones cgzones commented May 8, 2024

  • Constify read-only data

    Declare read-only data arrays const, to warn on accidental modification and let compilers place them in read-only memory sections.

  • De-duplicate strtoupper()

    Avoid the duplicate definition of strtoupper() in websocket.c, just use the one from util.h.

  • Avoid UB in character checking functions

    The functions classifying characters like isspace(3) require the input to be of type unsigned char or EOF.

  • Avoid out-of-bounds access in serial processing mode

    When using just one job for processing the input lines do not use the out-of-bounds index 1 instead of the valid one 0.
    This currently seems to only work since the stack space of the in this case unused threads array is used.

  • Insert the status code in the correct position

  • Avoid out-of-bounds access for invalid HTTP status codes

    Avoid array access in case the status code is less than 0 or bigger than 599.

    Also reduce the size of the codes array.

  • Avoid unnecessary string copies

    Do not duplicate the strings for enumeration keys, as they are read-only.

Declare read-only data arrays const, to warn on accidental modification
and let compilers place them in read-only memory sections.
Avoid the duplicate definition of strtoupper() in websocket.c, just use
the one from util.h.
The functions classifying characters like isspace(3) require the input
to be of type unsigned char or EOF.
When using just one job for processing the input lines do not use the
out-of-bounds index 1 instead of the valid one 0.  This currently seems
to only work since the stack space of the in this case unused threads
array is used.
Avoid array access in case the status code is less than 0 or bigger than
599.

Also reduce the size of the codes array.
Do not duplicate the strings for enumeration keys, as they are read-
only.
These two locations are only enabled via `--enable-debug`.
@allinurl allinurl force-pushed the master branch 6 times, most recently from 3c72d1e to c7ff4b4 Compare May 14, 2024 22:29
@allinurl allinurl merged commit b45ab0d into allinurl:master May 14, 2024
6 checks passed
@allinurl
Copy link
Owner

Great, thank you for addressing these issues. Merged!

@cgzones cgzones deleted the misc branch May 16, 2024 16:05
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