Skip to content

Add defensive zero-size guard to ucl_strlcpy_unsafe#392

Open
sage-mode-hunter wants to merge 1 commit into
vstakhov:masterfrom
sage-mode-hunter:harden-ucl-strlcpy
Open

Add defensive zero-size guard to ucl_strlcpy_unsafe#392
sage-mode-hunter wants to merge 1 commit into
vstakhov:masterfrom
sage-mode-hunter:harden-ucl-strlcpy

Conversation

@sage-mode-hunter

@sage-mode-hunter sage-mode-hunter commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Added an early return in ucl_strlcpy_unsafe() when siz == 0.

Fix

Added:

if (siz == 0) {
    return 0;
}

at the beginning of the function.

Why

The function assumes siz is at least 1, but adding this check makes it safer if an invalid value is ever passed. It also avoids undefined behavior from using siz - 1.

Compatibility

This change does not affect existing callers or valid inputs. It only adds a safe early return for the unexpected case where siz is 0.

@sage-mode-hunter

Copy link
Copy Markdown
Author

gentle ping

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.

1 participant