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

usUtils.cpp - Crash can occur if FormatMessage(...) fails #33

Closed
jeffdiclemente opened this Issue Aug 28, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@jeffdiclemente
Contributor

jeffdiclemente commented Aug 28, 2015

In us::GetLastErrorStr(), the buffer 'lpMsgBuf' returned from FormatMessage(...) is used without checking the return code of FormatMessage(...).
A crash can occur if FormatMessage(...) fails (i.e. lpMsgBuf will be uninitialized).

This error was found using VS 2013 code analysis.

@saschazelzer saschazelzer added the bug label Sep 23, 2015

@saschazelzer saschazelzer added this to the Release 3.0 milestone Sep 23, 2015

@saschazelzer saschazelzer self-assigned this Oct 11, 2015

jeffdiclemente added a commit that referenced this issue Oct 29, 2015

Fixed Windows bug in GetLastErrorStr()
Ran unit tests and Visual Studio 2013 static code analysis to verify the fix.

Fixes #33

Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com
@jeffdiclemente

This comment has been minimized.

Show comment
Hide comment
@jeffdiclemente

jeffdiclemente Oct 29, 2015

Contributor

closing issue as fixed by PR #52

Contributor

jeffdiclemente commented Oct 29, 2015

closing issue as fixed by PR #52

jeffdiclemente added a commit that referenced this issue Oct 29, 2015

Fixed Windows bug in GetLastErrorStr()
Ran unit tests and Visual Studio 2013 static code analysis to verify the fix.

Fixes #33

Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

smart pointer changes. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

change framework object to a smart pointer. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Fix merge error. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Fix merge error. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Change Framework object to smart pointer. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Revert back to previous state. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Smart pointer changes. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Avoid an extra copy of the smart pointer. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Minor spacing issues. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Refactored examples. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Smart Pointer changes. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

Smart Pointer changes. Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment