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

#46 の(とりあえずの)修正 #48

Merged
merged 1 commit into from Mar 7, 2019

Conversation

taro-yamada
Copy link
Contributor

現在一部のmalloc()で
foo *bar = ( foo * ) malloc( buzz ) ;
という形で"buffバイト"のヒープを確保したあとそのポインタに対して
bar[ buzz ] ;
のように"buff個目の要素"としてアクセスしているため、fooが1バイト場合を除き要素の後ろの部分でオーバーフローが発生しています。

例)
buzz=5、fooが1要素当たり4バイトの場合、確保されたメモリは5バイトなのに対して bar[5] は 4*5=20 バイト目となる

foo *bar = ( foo * ) malloc( sizeof( foo ) * buzz ) ;
として正しいバイトを確保するように修正します。

また、charは1バイトが保証されているため変更せず
Bytefは現状1バイトのようですがその保証が有るのか確認できなかったためsizeof(Bytef)に
末尾の +64 は番兵のようなので変更せず
としました。

現在一部のmalloc()で
foo *bar = ( foo * ) malloc( buzz ) ;
という形で"buffバイト"のヒープを確保したあとそのポインタに対して
bar[ buzz ] ;
のように"buff個目の要素"としてアクセスしているため、fooが1バイト場合を除き要素の後ろの部分でオーバーフローが発生しています。

例)
buzz=5、fooが1要素当たり4バイトの場合、確保されたメモリは5バイトなのに対して bar[5] は 4*5=20 バイト目となる

foo *bar = ( foo * ) malloc( sizeof( foo ) * buzz ) ;
として正しいバイトを確保するように修正します。

また、charは1バイトが保証されているため変更せず
Bytefは現状1バイトのようですがその保証が有るのか確認できなかったためsizeof(Bytef)に
末尾の +64 は番兵のようなので変更せず
としました。
@taro-yamada taro-yamada changed the title Fix #46 #46 の(とりあえずの)修正 Mar 6, 2019
@yama-natuki yama-natuki merged commit d4c026d into JDimproved:master Mar 7, 2019
@yama-natuki
Copy link
Collaborator

ありがとうございます

@ma8ma ma8ma added the bug バグの追跡 label Mar 7, 2019
@ma8ma ma8ma added this to In progress in State of JDim-v0.1.0+ via automation Mar 7, 2019
@ma8ma ma8ma moved this from In progress to Done in State of JDim-v0.1.0+ Mar 7, 2019
@taro-yamada taro-yamada deleted the fix_issue_46 branch March 8, 2019 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug バグの追跡
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants