Closed
Description
I noticed several bugs in 0.12.1 with detect_buffers logic inside a multi/exec block. These bugs can be reproduced with the following code:
var redis = require('redis');
function checkCallback(name) {
return function (err, res) {
if (err) {
console.log(name, "::", err.stack);
process.exit(1);
}
if (res) {
console.log(name, "::", res);
}
};
}
var client = redis.createClient({detect_buffers: true});
client.hmset("FOO", {"alpha":1, "beta":2}, checkCallback("Hmset"));
client.hgetall("FOO", checkCallback("Correct: normal hgetall"));
// Wrong: mangles data into [ { '1': ',', a: ',', p: 'h', b: 'e', t: 'a', ',': '2' } ]
client.multi().hgetall("FOO").exec(checkCallback("Bad: hgetall in multi"));
// Wrong: returns both values as strings, even though 'beta' wanted a buffer
client.multi()
.hget("FOO", "alpha")
.hget(new Buffer("FOO"), "beta")
.exec(checkCallback("Bad: incorrect types for hget in multi"));
// Crashes due to attempting to do a .toString('binary') on a number
client.multi().hgetall(new Buffer("FOO")).exec(checkCallback("Bad: binary hgetall in multi"));
I'll attach a pull request to fix these bugs in a short bit. Thanks for the library!
Also: this is a duplicate of bug #263, but that issue hasn't been touched since mid-2013, so I elected to start fresh. Also, the PR I'll attach doesn't touch the parser, so it shouldn't conflict with hiredis.
Metadata
Metadata
Assignees
Labels
No labels