Skip to content

Function strlcpy_is_not_posix truncated the last character of every s… - #79

Merged
froz42 merged 3 commits into
42paris:masterfrom
luna7111:master
May 15, 2026
Merged

Function strlcpy_is_not_posix truncated the last character of every s…#79
froz42 merged 3 commits into
42paris:masterfrom
luna7111:master

Conversation

@luna7111

@luna7111 luna7111 commented Jul 26, 2025

Copy link
Copy Markdown
Contributor

Fixes #78
Function strlcpy_is_not_posix truncated the last character of every string it copied. Removed the "- 1" in the loop condition so it copies the entire string.

Refer to the issue for a more in-detail description.

My login is ldel-val, slack me if you need to talk about this PR :)

…tring it copied. Removed the "- 1" in the loop so it copies the entire string.
@froz42

froz42 commented Apr 16, 2026

Copy link
Copy Markdown
Member

Hello, could you clarify that was the concret effect of this bug ? in what mlx functions ?

@froz42 froz42 self-assigned this Apr 16, 2026
@froz42

froz42 commented Apr 16, 2026

Copy link
Copy Markdown
Member

ok just saw your issue, but i need to make sure this does not break other things

@luna7111

Copy link
Copy Markdown
Contributor Author

hey! it's been a while since i made this PR.

Seeing that you work at 42 Paris you must be very busy with other stuff so if you want me to take a better look at this and make tests for every call to this function just tell me, i have the time.

Sorry if the issue and/or the PR weren't detailed enough, thank you for taking the time to take a look at the issue.

@luna7111

luna7111 commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

the function strlcpy_is_not_posix() is only used by the function mlx_int_static_line(), which is only used by mlx_xpm_to_image(), which passes the function to mlx_int_parse_xpm() as an argument, it wont break anything else in the library.

i added a test to test/main.c to check the mlx_xpm_to_image() function now that it works, it includes the open.xpm file to the code, as writing the raw xpm data in the source file seemed too dirty. I added a comment because otherwise including an xpm file seemed a little bit unintuitive.

please, tell me if there is anything i could/should change.

@froz42
froz42 merged commit b8de9b4 into 42paris:master May 15, 2026
3 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.

strlcpy_is_not_posix truncates valid data and causes crash in mlx_xpm_to_image

2 participants