Skip to content

Commit

Permalink
fixed infinite loop bug in zero padding unpad
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Quade committed Mar 17, 2017
1 parent 4338ce0 commit 5bfe6d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pad-zeropadding.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ CryptoJS.pad.ZeroPadding = {

// Unpad
var i = data.sigBytes - 1;
while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
i--;
for (var i = data.sigBytes - 1; i >= 0; i--) {
if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
data.sigBytes = i + 1;
break;
}
}
data.sigBytes = i + 1;
}
};

0 comments on commit 5bfe6d5

Please sign in to comment.