Skip to content

Compiler: use safer string functions#540

Open
chqrlie wants to merge 1 commit into
c2lang:masterfrom
chqrlie:string-safety
Open

Compiler: use safer string functions#540
chqrlie wants to merge 1 commit into
c2lang:masterfrom
chqrlie:string-safety

Conversation

@chqrlie

@chqrlie chqrlie commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
  • add pstrcpy and pstrcat to string.c2i as safer alternatives for strcpy and strcat.
  • use snprintf instead of sprintf
  • use pstrcpy and pstrcat instead of strcpy and strcat
  • fix strlcpy and strlcat for conformity with BSD semantics. pstrcpy and pstrcat argument order and semantics are more convenient for readability and efficiency.

* add `pstrcpy` and `pstrcat` to string.c2i as safer alternatives
  for `strcpy` and `strcat`.
* use `snprintf` instead of `sprintf`
* use `pstrcpy` and `pstrcat` instead of `strcpy` and `strcat`
* use `elemsof` instead of `sizeof` for array lengths
* fix `strlcpy` and `strlcat` for conformity with BSD semantics.
  `pstrcpy` and `pstrcat` argument order and semantics are more
  convenient for readability and efficiency.
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