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

Fix crash (integer overflow) in Device::getTextureDataForText (ios) #13999

Merged
merged 1 commit into from
Oct 4, 2015
Merged

Fix crash (integer overflow) in Device::getTextureDataForText (ios) #13999

merged 1 commit into from
Oct 4, 2015

Conversation

igorzel
Copy link

@igorzel igorzel commented Sep 22, 2015

Explanation

There was the problem when height and width were typecast to short
integer. So for values bigger than sizeof(short) we had integer overflow. Values may became negative.

Steps to reproduce:

Create simple application with cocos2d::ui::EditBox. Start it. Add 1000 (just
example) characters at a time to the edit box. Method
Device::getTextureDataForText will be called and there will be integer
overflow for height and/or width:

screen shot 2015-09-22 at 16 00 34
As a result application will crash later.

Notes

This fix is related to platform (IOS) dependent code! So it is in CCDevice-ios.mm.

…ios.mm)

There was the problem when “height” and “width” were typecast to short
integer. So for values more than sizeof(short) we had integer overflow.

Steps to reproduce:
Create simple application with EditBox. Start it. Add 1000 (just
example) characters at a time to the EditBox. Method
Device::getTextureDataForText will be called and there will be integer
overflow for “height” and “width”. As a result application will crash
later.
@igorzel igorzel changed the title Fixed integer overflow in Device::getTextureDataForText (ios) Fix integer overflow in Device::getTextureDataForText (ios) Sep 23, 2015
@igorzel
Copy link
Author

igorzel commented Sep 25, 2015

[ci rebuild]

@igorzel igorzel changed the title Fix integer overflow in Device::getTextureDataForText (ios) Fix crash (integer overflow) in Device::getTextureDataForText (ios) Sep 25, 2015
pandamicro added a commit that referenced this pull request Oct 4, 2015
Fix crash (integer overflow) in Device::getTextureDataForText (ios)
@pandamicro pandamicro merged commit b38eec4 into cocos2d:v3 Oct 4, 2015
@pandamicro
Copy link
Contributor

Thanks for your contribution

@pandamicro pandamicro added this to the v3.9 milestone Oct 4, 2015
@igorzel igorzel deleted the FixIntegerOverflowInIosDevice branch October 4, 2015 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants