Issue 28379: PyUnicode_CopyCharacters could lead to undefined behaviour (original) (raw)

Created on 2016-10-06 18:15 by xiang.zhang, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
PyUnicode_CopyCharacters.patch xiang.zhang,2016-10-06 18:27 review
PyUnicode_CopyCharacters_v2.patch xiang.zhang,2016-10-07 13:14 review
unicode_copycharacters.patch xiang.zhang,2016-10-09 04:41 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft,2017-03-31 16:36
Messages (10)
msg278202 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-10-06 18:15
Currently PyUnicode_CopyCharacters doesn't check arguments thoroughly. This could lead to undefined behaviour or crash in debug mode. For example, from_start > len(from), how_many < 0. Another case is that when how_many > len(from), it will choose len(from) but this can still fail since from_start can > 0. The doc of it is also not perfect, it does not necessarily return 0 on success.
msg278205 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-06 19:08
Added comments on Rietveld. I don't know whether tests for this function are needed. It is public, but is not a part of stable API.
msg278240 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-10-07 13:14
v2 applies Serhiy's suggestions.
msg278322 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-10-08 19:48
New changeset 13addd71b751 by Serhiy Storchaka in branch '3.5': Issue #28379: Added sanity checks and tests for PyUnicode_CopyCharacters(). https://hg.python.org/cpython/rev/13addd71b751
msg278323 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-08 19:50
Thank you for your contribution.
msg278342 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-10-09 04:41
Thanks Serhiy! But sorry I think I have made a mistake. In unicode_copycharacters we don't need PyUnicode_READY since it has been done in argument parse. Could you remove it?
msg278356 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-10-09 12:38
New changeset 1be8cd7cee92 by Serhiy Storchaka in branch 'default': Issue #28379: Removed redundant check. https://hg.python.org/cpython/rev/1be8cd7cee92
msg278359 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-10-09 13:31
We don't need to remove it for 3.5 and 3.6?
msg278373 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-09 16:54
This is just a cleaning up of not very important code.
msg278374 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-10-09 17:00
Fine. :-)
History
Date User Action Args
2022-04-11 14:58:37 admin set github: 72565
2017-03-31 16:36:33 dstufft set pull_requests: + <pull%5Frequest1061>
2016-10-09 17:00:20 xiang.zhang set messages: +
2016-10-09 16:54:19 serhiy.storchaka set messages: +
2016-10-09 13:31:30 xiang.zhang set messages: +
2016-10-09 12:40:04 serhiy.storchaka set status: open -> closedstage: patch review -> resolved
2016-10-09 12:38:10 python-dev set messages: +
2016-10-09 04:41:43 xiang.zhang set status: closed -> openfiles: + unicode_copycharacters.patchmessages: + stage: resolved -> patch review
2016-10-08 19:50:20 serhiy.storchaka set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2016-10-08 19:48:31 python-dev set nosy: + python-devmessages: +
2016-10-07 20:52:19 serhiy.storchaka set assignee: serhiy.storchaka
2016-10-07 13:14:03 xiang.zhang set files: + PyUnicode_CopyCharacters_v2.patchmessages: +
2016-10-06 19:08:42 serhiy.storchaka set messages: +
2016-10-06 18:27:17 xiang.zhang set files: + PyUnicode_CopyCharacters.patch
2016-10-06 18:27:04 xiang.zhang set files: - PyUnicode_CopyCharacters.patch
2016-10-06 18:15:04 xiang.zhang create