From ed8c43d2f3d20dec77a1206cfe80b8dfb5db5811 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 9 Aug 2009 18:10:16 +0200 Subject: [PATCH] Bugfix: Negative ints in HTTP's on_body and node.fs.read() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to the error fixed in 9d3ed1bb9231798df8a081746fd0dc75900d8276. Reported by Felix Geisendörfer. --- src/file.cc | 3 ++- src/http.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/file.cc b/src/file.cc index 368068cbfa..cfabaa9278 100644 --- a/src/file.cc +++ b/src/file.cc @@ -285,7 +285,8 @@ AfterRawRead(eio_req *req) size_t len = req->result; Local array = Array::New(len); for (unsigned int i = 0; i < len; i++) { - array->Set(Integer::New(i), Integer::New(buf[i])); + unsigned char val = reinterpret_cast(buf)[i]; + array->Set(Integer::New(i), Integer::New(val)); } argv[0] = array; argv[1] = Integer::New(req->result); diff --git a/src/http.cc b/src/http.cc index 945d98856b..0958b5a2fa 100644 --- a/src/http.cc +++ b/src/http.cc @@ -196,7 +196,7 @@ HTTPConnection::on_body (http_parser *parser, const char *buf, size_t len) // raw encoding Local array = Array::New(len); for (size_t i = 0; i < len; i++) { - char val = static_cast(buf)[i]; + unsigned char val = reinterpret_cast(buf)[i]; array->Set(Integer::New(i), Integer::New(val)); } argv[0] = array;