Skip to content
Browse files

Fixed a token parsing bug

Fencepost error with calculating the correct buffer length to store the token. This should fix an out-of-bounds error I got once with a token of incorrect length.
  • Loading branch information...
1 parent 8056c34 commit 2968dbbd20fc2f019cc75db72ce82e79d047829c @argon committed Mar 7, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/apn.js
View
2 lib/apn.js
@@ -199,7 +199,7 @@ var Device = function (/* deviceToken, ascii=true */) {
Device.prototype.parseToken = function (token) {
token = token.replace(/\s/g, "");
- length = Number(token.length / 2);
+ length = Math.ceil(token.length / 2);
hexToken = new Buffer(length);
for(var i=0; i < token.length; i+=2) {
word = token[i];

0 comments on commit 2968dbb

Please sign in to comment.
Something went wrong with that request. Please try again.