Skip to content

ICU-21118 check that dst and src are not null in uprv_memcpy - #1489

Merged
erik0686 merged 1 commit into
unicode-org:masterfrom
erik0686:add-check-to-macros
Dec 10, 2020
Merged

erik0686 merged 1 commit into
unicode-org:masterfrom
erik0686:add-check-to-macros

Conversation

@erik0686

Copy link
Copy Markdown
Contributor

It was pointed out that uprv_memcpy() and uprv_memmove() internally use memcpy and memmove respectively, and these do not allow dst or src to be null. In this PR, I am adding a check for Debug mode for these two functions to make sure that doesn't happen.

After building ICU on Linux there was a case where adding this check could bring errors on the tests, so I am adding a check to uloc_tag.cpp as well.

After this, I built again on Linux and Windows and found no more issues. And all tests pass successfully :D

Checklist

@jira-pull-request-webhook

Copy link
Copy Markdown

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

@jefgen jefgen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Erik! A few minor nits... :)

Comment thread icu4c/source/common/uloc_tag.cpp Resolved
Comment thread icu4c/source/common/uloc_tag.cpp Resolved
@jira-pull-request-webhook

Copy link
Copy Markdown

Notice: the branch changed across the force-push!

  • icu4c/source/common/uloc_tag.cpp is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@jira-pull-request-webhook

Copy link
Copy Markdown

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

@jefgen
jefgen requested a review from markusicu November 30, 2020 22:57
Comment thread icu4c/source/common/cmemory.h Resolved
jefgen
jefgen previously approved these changes Nov 30, 2020

@jefgen jefgen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but please wait for Markus to review as well. Thanks!

@markusicu markusicu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly lgtm

Comment thread icu4c/source/common/cmemory.h Resolved
Comment thread icu4c/source/common/uloc_tag.cpp Resolved
@jira-pull-request-webhook

Copy link
Copy Markdown

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

@erik0686
erik0686 requested review from jefgen and markusicu December 9, 2020 21:49

@markusicu markusicu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm tnx

@jefgen jefgen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @erik0686!

@erik0686
erik0686 merged commit 17f725f into unicode-org:master Dec 10, 2020
@tedyu

tedyu commented Jan 19, 2021

Copy link
Copy Markdown

I checked release 68.2 but I didn't find this fix among the JIRAs.

which release would contain this fix ? If none, when would the next release be made ?

thanks

@jefgen

jefgen commented Jan 19, 2021 •

Copy link
Copy Markdown
Member

I checked release 68.2 but I didn't find this fix among the JIRAs.
which release would contain this fix ? If none, when would the next release be made ?

This PR was merged after the 68.2 release, so this change wouldn't be included as part of it.
The most current release is 68.2, so that would mean that there actually isn't any releases out with this change.
The next release would be 69.1, which I think would be sometime in March/April.

@tedyu

tedyu commented Jan 19, 2021

Copy link
Copy Markdown

Thanks for the response.

I will watch for the next release.

@jefgen

jefgen commented Jan 19, 2021

Copy link
Copy Markdown
Member

FWIW, you could possibly consider cherry-picking this change onto maint/maint-68 if you need the change sooner.

The change in icu4c/source/common/cmemory.h is a no-op for release builds; the only real change is the 3 line change in icu4c/source/common/uloc_tag.cpp. :)

@tedyu

tedyu commented Jan 19, 2021

Copy link
Copy Markdown

Assuming 68.3 release would come sooner than 69.1, it is nice to cherry-pick the fix.

We have been experiencing the issue (using 67.1) for quite a while.

Thanks

jefgen added a commit to microsoft/icu that referenced this pull request Jan 20, 2021
This change cherry-picks two tickets from the upstream ICU repo that were merged after the ICU 68.2 release.

- ICU-21427 Don't ignore already checked-in files under "tools/cldr/lib"
- ICU-21118 check that dst and src are not null in uprv_memcpy

The first one I had already done with #52, so this is mostly just making an update for the comments and to record it in the `changelog.md` file.

The second one was fixed by @erik0686, and prevents undefined behavior in `ultag_parse`.

CP: ICU-21118 check that dst and src are not null in uprv_memcpy
https://unicode-org.atlassian.net/browse/ICU-21118
unicode-org/icu#1489

CP: ICU-21427 Don't ignore already checked-in files under "tools/cldr/lib"
https://unicode-org.atlassian.net/browse/ICU-21427
unicode-org/icu#1500

Update changelog.md for cherry-picked tickets.
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.

4 participants