Skip to content

Changes to avoid strncpy in EE and host code#881

Merged
fjtrujy merged 3 commits into
ps2dev:masterfrom
uyjulian:no_strncpy
Jul 7, 2026
Merged

Changes to avoid strncpy in EE and host code#881
fjtrujy merged 3 commits into
ps2dev:masterfrom
uyjulian:no_strncpy

Conversation

@uyjulian

@uyjulian uyjulian commented Jul 2, 2026

Copy link
Copy Markdown
Member

strncpy has major flaws:

  • Will zero initialize extra memory after NULL terminator
  • Will not NULL terminate if written bytes is equal to buffer size

@AKuHAK

AKuHAK commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

doh, isnt it supposed to be rather fixed in strncpy implementation?

@uyjulian

uyjulian commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

The strncpy in newlib is the C standard specification. The implementation is correct, but the specification has footguns

uyjulian added 3 commits July 4, 2026 10:52
It has major flaws:
* Will zero initialize extra memory after NULL terminator
* Will not NULL terminate if written bytes is equal to buffer size
@AKuHAK

AKuHAK commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

got it, thanks

@fjtrujy fjtrujy merged commit fde25e3 into ps2dev:master Jul 7, 2026
13 checks passed
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.

3 participants