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

Potential Integer Overflow vulnerability in src/Stk.cpp #116

Open
KSB21ST opened this issue Sep 3, 2021 · 0 comments
Open

Potential Integer Overflow vulnerability in src/Stk.cpp #116

KSB21ST opened this issue Sep 3, 2021 · 0 comments

Comments

@KSB21ST
Copy link

KSB21ST commented Sep 3, 2021

It seems that there exists a potential integer overflow. Please find the following description:

  1. Call to function FileRead :: open(...)

    file_.open( fileName, raw );

  2. In FileRead :: open(...), Call to function getWavInfo(...)

    result = getWavInfo( fileName.c_str() );

  3. In getWavInfo(...), variable temp is read from external source

    if ( fread(&temp, 2, 1, fd_) != 1 ) goto error;

  4. channels_ can be an arbitrary integer

    channels_ = (unsigned int ) temp;

  5. Back to function in FileWrite: fix warnings #1, call to fileSize(...)

    if ( file_.fileSize() > chunkThreshold_ ) {

    unsigned long fileSize( void ) const { return fileSize_; };

  6. In the same function with make casts in Fir.h explicit #6, Call to function StkFrames :: resize(...) with channels_ as second argument

    unsigned int channels( void ) const { return channels_; };

    data_.resize( chunkSize_ + 1, file_.channels() );

  7. In function StkFrames :: resize(...), if channels_ is large enough, the multiplication can cause integer overflow

    stk/src/Stk.cpp

    Line 296 in 1fec6e0

    nFrames_ = nFrames;

    stk/src/Stk.cpp

    Line 299 in 1fec6e0

    size_ = nFrames_ * nChannels_;

  8. In the same function with iOS-friendly static library #8, if channels_ is large enough (from iOS-friendly static library #8), allocation of memory with multiplication may cause integer overflow

    stk/src/Stk.cpp

    Line 302 in 1fec6e0

    data_ = (StkFloat *) malloc( size_ * sizeof( StkFloat ) );

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

No branches or pull requests

1 participant