Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

PDU writer bug fix #11

Merged
merged 4 commits into from Mar 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
Shorty - SMPP Client / Server Shorty - SMPP Client / Server
================================ ================================
Version 0.5.0 Created by Evan Coury and Ben Youngblood Version 0.5.4 Created by Evan Coury and Ben Youngblood




Introduction Introduction
Expand Down
12 changes: 6 additions & 6 deletions lib/pdu-writer.js
Expand Up @@ -52,7 +52,7 @@ exports.write = function(pdu) {
} else if (field.type === "c-string") { } else if (field.type === "c-string") {
// get the actual byte length of the string, then add 1 for the // get the actual byte length of the string, then add 1 for the
// null terminator // null terminator

// Don't try to do anything to a buffer // Don't try to do anything to a buffer
if (!Buffer.isBuffer(field.value)) { if (!Buffer.isBuffer(field.value)) {
if (typeof field.value === 'string') { if (typeof field.value === 'string') {
Expand Down Expand Up @@ -155,7 +155,7 @@ exports.write = function(pdu) {
} }
} else if (field.type === "c-string") { } else if (field.type === "c-string") {
// TODO still need to do error checking for out-of-bounds lengths // TODO still need to do error checking for out-of-bounds lengths

/** /**
* Unlike with reading, this method can actually be the same for * Unlike with reading, this method can actually be the same for
* fixed- and variable-length strings * fixed- and variable-length strings
Expand Down Expand Up @@ -187,12 +187,12 @@ exports.write = function(pdu) {
if (definition.octets !== undefined) { if (definition.octets !== undefined) {
length += definition.octets; length += definition.octets;
} else { } else {
if (Buffer.isBuffer(pdu.optional_params[param])) { if (Buffer.isBuffer(param)) {
length += pdu.optional_params[param].length; length += param.length;
} else { } else {
length += Buffer.byteLength(pdu.optional_params[param]); length += Buffer.byteLength(param);
} }
} }


// Write the tag and length -- 2 bytes each // Write the tag and length -- 2 bytes each
buffer.writeUInt16BE(definition.tag, offset); buffer.writeUInt16BE(definition.tag, offset);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{ {
"name": "shorty", "name": "shorty",
"description": "An asynchronous SMPP client and server built on Node.js.", "description": "An asynchronous SMPP client and server built on Node.js.",
"version": "0.5.3", "version": "0.5.4",
"directories": { "lib": "./lib" }, "directories": { "lib": "./lib" },
"main" : "./lib/shorty", "main" : "./lib/shorty",
"maintainers": [ "maintainers": [
Expand Down