Skip to content

Commit

Permalink
Merge pull request #5 from Zentyal/ejhernandez/fix-crash-decoding-quo…
Browse files Browse the repository at this point in the history
…ted-printable-no-regressions

Fix crash when decoding a = at end of the data
  • Loading branch information
blaxter committed Nov 27, 2014
2 parents da3c1b4 + bd19494 commit 8ce09d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sope-core/NGExtensions/NGQuotedPrintableCoding.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,21 @@ int NGDecodeQuotedPrintableX(const char *_src, unsigned _srcLen,
destCnt++;
}
else {
if ((_srcLen - cnt) > 2) {
if ((_srcLen - cnt) > 1) {
signed char c1, c2;

cnt++; // skip '='
c1 = _src[cnt]; // first hex digit

if (c1 == '\r' || c1 == '\n') {
if (_src[cnt + 1] == '\r' || _src[cnt + 1] == '\n' )
if (cnt < _srcLen && (_src[cnt + 1] == '\r' || _src[cnt + 1] == '\n' ))
cnt++;
continue;
}

if (cnt == _srcLen) /* We have reached the end of the _src */
break;

c1 = __hexToChar(c1);

cnt++; // skip first hex digit
Expand Down

0 comments on commit 8ce09d9

Please sign in to comment.