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

Use a custom implementation of wcsdup on Windows, so that malloc/free… #7540

Closed
wants to merge 3 commits into from

Conversation

@Myriachan
Copy link
Contributor

@Myriachan Myriachan commented Aug 6, 2021

… overrides from curl_global_init are used for wcsdup correctly.

… overrides from curl_global_init are used for wcsdup correctly.
lib/strdup.c Outdated
size_t lengthnul;
size_t lengthbytes;

if (SIZE_MAX - length < 1)
Copy link
Contributor Author

@Myriachan Myriachan Aug 6, 2021

These overflow checks are probably unnecessary, because presumably the wchar string has a size fitting in size_t. I don't know what your standards are for checks like these.

Copy link
Member

@jay jay left a comment

stdint may not be available and shouldn't be necessary. curl_setup defines SIZE_T_MAX, you can use that instead. Also Curl_wcsdup doesn't need so many lines, you can do a single check like
if(length > (SIZE_T_MAX / sizeof(wchar_t)) - 1)
return NULL;
return (wchar_t *)Curl_memdup(src, (length + 1) * sizeof(wchar_t))

@jay
Copy link
Member

@jay jay commented Aug 7, 2021

@Myriachan
Copy link
Contributor Author

@Myriachan Myriachan commented Aug 7, 2021

stdint may not be available and shouldn't be necessary. curl_setup defines SIZE_T_MAX, you can use that instead. Also Curl_wcsdup doesn't need so many lines, you can do a single check like

Thanks! Didn't know about libcurl having a SIZE_T_MAX. Also, I didn't know how wordy the coding style should be.

@Myriachan Myriachan marked this pull request as ready for review Aug 7, 2021
bagder
bagder approved these changes Aug 8, 2021
@bagder bagder requested a review from jay Aug 8, 2021
@bagder
Copy link
Member

@bagder bagder commented Aug 9, 2021

Thanks!

@bagder bagder closed this in 76e047f Aug 9, 2021
@bagder bagder removed the request for review from jay Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants