Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

[jpgcoder.cc] fix undefined behavior #76

Merged
merged 1 commit into from
Dec 13, 2016

Conversation

bryonglodencissp
Copy link
Contributor

馃悰 label: security

Greetings,

It's always good to initialize integer variables, at least to 0, because if we try to retrieve its value before it gets assigned any actual (non-garbage) value, then it results in undefined behavior, e.g. line number 2937 of lepton/src/lepton/jpgcoder.cc.

REF: http://cwe.mitre.org/data/definitions/457.html

Signed-off-by: Bryon Gloden, CISSP庐 cissp@bryongloden.com

[lepton/src/lepton/jpgcoder.cc:2937]: (error) using uninitialized variable: mcu

Signed-off-by: Bryon Gloden, CISSP庐 cissp@bryongloden.com
@@ -2475,7 +2475,7 @@ bool decode_jpeg(const std::vector<std::pair<uint32_t, uint32_t> > & huff_input_
int rstw; // restart wait counter

int cmp, bpos, dpos;
int mcu, sub, csc;
Copy link
Contributor Author

@bryonglodencissp bryonglodencissp Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line no. 2478 | 1. declaring variable mcu without initializer
Line no. 2492 | 2. condition true, taking true branch
Line no. 2495 | 3. condition type != 218, taking true branch
Line no. 2496 | 4. condition (int)hpos >= hers, taking true branch
Line no. 2496 | 5. breaking from loop
Line no. 2509 | 6. condition type != 218, taking true branch
Line no. 2509 | 7. breaking from loop
Line no. 2933 | 8. condition early_eof_encrountered, taking true branch
Line no. 2937 | 9. using uninitialized value mcu

@danielrh danielrh merged commit 7e9ef87 into dropbox:master Dec 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants