Commit Graph

8291 Commits (01e29202193cfc4257d6c638b8c08b7fcc2c9931)

Author SHA1 Message Date
isaacs 01e2920219 http: Don't try to destroy nonexistent sockets
Fixes #3740

In the case of pipelined requests, you can have a situation where
the socket gets destroyed via one req/res object, but then trying
to destroy *another* req/res on the same socket will cause it to
call undefined.destroy(), since it was already removed from that
message.

Add a guard to OutgoingMessage.destroy and IncomingMessage.destroy
to prevent this error.
2013-04-22 09:54:04 -07:00
isaacs 1d794ec43e test: fix dgram-bind-default-address on osx
Allow the IPv4-mapped-as-IPv6 style address.
2013-04-22 08:56:29 -07:00
isaacs 4bf1d1007f crypto: LazyTransform on properties, not methods
It needs to apply the Transform class when the _readableState,
_writableState, or _transformState properties are accessed,
otherwise things like setEncoding and on('data') don't work
properly.

Also, the methods wrappers are no longer needed, since they're only
problematic because they access the undefined properties.
2013-04-21 09:33:10 -04:00
mscdex c4379a5554 src: fix potential memory leak on early return 2013-04-20 23:30:21 -04:00
mscdex 2322580dfb src: don't initialize variable before assignment 2013-04-20 23:30:20 -04:00
isaacs 0b04abcb10 blog: v0.11.1 does not work on windows x64 2013-04-19 09:22:06 -07:00
isaacs 223f22a30d blog: Post about 0.11.1 2013-04-19 09:12:53 -07:00
isaacs 56e90dacb3 blog: Post about 0.10.4 2013-04-19 09:12:22 -07:00
Sean Silva 63466e5cae doc: document value of `this` inside listeners
Fixes #5326.
2013-04-19 11:58:18 +02:00
Ryan Doenges 6101eb184d assert: put info in err.message, not err.name
4716dc6 made assert.equal() and related functions work better by
generating a better toString() from the expected, actual, and operator
values passed to fail(). Unfortunately, this was accomplished by putting
the generated message into the error's `name` property. When you passed
in a custom error message, the error would put the custom error into
`name` *and* `message`, resulting in helpful string representations like
"AssertionError: Oh no: Oh no".

This commit resolves that issue by storing the generated message in the
`message` property while leaving the error's name alone and adding
a regression test so that this doesn't pop back up later.

Closes #5292.
2013-04-18 15:08:35 -07:00
Ben Noordhuis a835a2fc47 website: add link to nightlies on download page 2013-04-18 22:06:04 +02:00
Trevor Norris 659fb238e7 crypto: fix return Local Handle w/o scope.Close()
A new String was being created and returned, but was not sent through
the scope.Close(), which caused it to be cleaned up before being
returned.
2013-04-18 01:30:36 +02:00
Ben Noordhuis 92023b4b37 dgram: fix no address bind()
I broke dgram.Socket#bind(port, cb) almost a year ago in 332fea5a but
it wasn't until today that someone complained and none of the tests
caught it because they all either specify the address or omit the
callback.

Anyway, now it works again and does what you expect: it binds the
socket to the "any" address ("0.0.0.0" for IPv4 and "::" for IPv6.)
2013-04-18 00:54:57 +02:00
Ben Noordhuis 2e70ddad9d test: make stdout-close-unref work in test runner
process.stdout isn't fully initialized yet by the time the test starts
when invoked with `python tools/test.py`. Use process.stdin instead and
force initialization with process.stdin.resume().
2013-04-18 00:02:51 +02:00
Kelly Gerber 36503b523d docs: update path.join() example for v0.10
The current example shows the behavior of v0.8. In v0.10 arguments
to path.join() must be strings; otherwise, an exception is thrown.
2013-04-17 00:04:17 +02:00
Ryan Graham b02b93b2a2 doc: note a gotcha with http.Server sockets 2013-04-16 23:44:00 +02:00
Ben Noordhuis ccd37226c6 handle_wrap: fix NULL pointer dereference
Fix a NULL pointer dereference in src/handle_wrap.cc which is really a
use-after-close bug.

The test checks that unref() after close() works on process.stdout but
this bug affects everything that derives from HandleWrap. I discovered
it because child processes would sometimes quit for no reason (that is,
no reason until I turned on core dumps.)
2013-04-16 23:11:03 +02:00
Stanislav Ochotnicky 7592615aaa test: preserve process.env after test-init exec
When LD_LIBRARY_PATH is overriden for custom builds we need to preserve
it for child processes. To be sure we preserve whole environment of
parent process and just add TEST_INIT variable to it.
2013-04-16 17:05:51 +02:00
Stanislav Ochotnicky 47198af55a test: preserve process.env in forked child_process
When LD_LIBRARY_PATH is overriden for custom builds we need to preserve
it for forked process. There are possibly other environment variables
that could cause test failures so we preserve whole environment of
parent process.
2013-04-16 17:05:51 +02:00
Ben Noordhuis d58ee7e5c7 os: unbreak windows build
Windows doesn't have MAXHOSTNAMELEN. Introduced in afbadde.
2013-04-15 22:39:03 +02:00
Ben Noordhuis afbaddecd3 os: handle 256 character hostnames
Fix a (rather academic) buffer overflow. MAXHOSTNAMELEN is 256 on most
platforms, which means the buffer wasn't big enough to hold the
trailing nul byte on a system with a maximum length hostname.
2013-04-15 21:13:29 +02:00
Ben Noordhuis 78c5de598b os: fix unlikely buffer overflow in os.type()
* Fix a buffer overflow that happens iff strlen(info.sysname) > 255.
* Check the return value of uname().
2013-04-15 20:57:14 +02:00
isaacs 8ee43006b8 build: Typo in tools/msvs/msi/product.wxs 2013-04-11 20:40:05 -07:00
isaacs b0de1e4a41 stream: Fix unshift() race conditions
Fix #5272

The consumption of a readable stream is a dance with 3 partners.

1. The specific stream Author (A)
2. The Stream Base class (B), and
3. The Consumer of the stream (C)

When B calls the _read() method that A implements, it sets a 'reading'
flag, so that parallel calls to _read() can be avoided.  When A calls
stream.push(), B knows that it's safe to start calling _read() again.

If the consumer C is some kind of parser that wants in some cases to
pass the source stream off to some other party, but not before "putting
back" some bit of previously consumed data (as in the case of Node's
websocket http upgrade implementation).  So, stream.unshift() will
generally *never* be called by A, but *only* called by C.

Prior to this patch, stream.unshift() *also* unset the state.reading
flag, meaning that C could indicate the end of a read, and B would
dutifully fire off another _read() call to A.  This is inappropriate.
In the case of fs streams, and other variably-laggy streams that don't
tolerate overlapped _read() calls, this causes big problems.

Also, calling stream.shift() after the 'end' event did not raise any
kind of error, but would cause very strange behavior indeed.  Calling it
after the EOF chunk was seen, but before the 'end' event was fired would
also cause weird behavior, and could lead to data being lost, since it
would not emit another 'readable' event.

This change makes it so that:

1. stream.unshift() does *not* set state.reading = false
2. stream.unshift() is allowed up until the 'end' event.
3. unshifting onto a EOF-encountered and zero-length (but not yet
end-emitted) stream will defer the 'end' event until the new data is
consumed.
4. pushing onto a EOF-encountered stream is now an error.

So, if you read(), you have that single tick to safely unshift() data
back into the stream, even if the null chunk was pushed, and the length
was 0.
2013-04-11 16:12:48 -07:00
isaacs 440bc060b9 Now working on v0.10.5 2013-04-11 11:07:08 -07:00
isaacs bf8ed11825 Merge branch 'v0.10.4-release' into v0.10 2013-04-11 11:06:37 -07:00
isaacs 22c7d134e2 lint 2013-04-11 11:06:20 -07:00
isaacs 50be39792a blog: Fix title for v0.8.23 release 2013-04-11 11:06:20 -07:00
isaacs 9712aa9f76 2013.04.11, Version 0.10.4 (Stable)
* uv: Upgrade to 0.10.4

* npm: Upgrade to 1.2.18

* v8: Avoid excessive memory growth in JSON.parse (Fedor Indutny)

* child_process, cluster: fix O(n*m) scan of cmd string (Ben Noordhuis)

* net: fix socket.bytesWritten Buffers support (Fedor Indutny)

* buffer: fix offset checks (Łukasz Walukiewicz)

* stream: call write cb before finish event (isaacs)

* http: Support write(data, 'hex') (isaacs)

* crypto: dh secret should be left-padded (Fedor Indutny)

* process: expose NODE_MODULE_VERSION in process.versions (Rod Vagg)

* crypto: fix constructor call in crypto streams (Andreas Madsen)

* net: account for encoding in .byteLength (Fedor Indutny)

* net: fix buffer iteration in bytesWritten (Fedor Indutny)

* crypto: zero is not an error if writing 0 bytes (Fedor Indutny)

* tls: Re-enable check of CN-ID in cert verification (Tobias Müllerleile)
2013-04-11 09:39:16 -07:00
isaacs 1ccae9cb1b npm: Upgrade to 1.2.18 2013-04-11 09:16:47 -07:00
isaacs e5fdc4d6f1 uv: Upgrade to v0.10.4 2013-04-11 09:07:22 -07:00
Ben Noordhuis 212eb8a52e child_process: fix O(n*m) scan of cmd string
Don't scan the whole string for a "NODE_" substring, just check that
the string starts with the expected prefix.

This is a reprise of dbbfbe7 but this time for the child_process
module.
2013-04-11 13:53:18 +02:00
Ben Noordhuis dbbfbe74ca cluster: fix O(n*m) scan of cmd string
Don't scan the whole string for a "NODE_CLUSTER_" substring, just check
that the string starts with the expected prefix. The linear scan was
causing a noticeable (but unsurprising) slowdown on messages with a
large .cmd string property.
2013-04-11 13:42:34 +02:00
Ben Noordhuis cd96f0aba8 src: don't SetInternalField() in ObjectWrap dtor
Call SetPointerInInternalField(0, NULL) rather than
SetInternalField(0, Undefined()).

Fixes the following spurious NULL pointer dereference in debug builds:

  #0  0x03ad2821 in v8::internal::FixedArrayBase::length ()
  #1  0x03ad1dfc in v8::internal::FixedArray::get ()
  #2  0x03ae05dd in v8::internal::Context::global_object ()
  #3  0x03b6b87d in v8::internal::Context::builtins ()
  #4  0x03ae1871 in v8::internal::Isolate::js_builtins_object ()
  #5  0x03ab4fab in v8::CallV8HeapFunction ()
  #6  0x03ab4d4a in v8::Value::Equals ()
  #7  0x03b4f38b in CheckEqualsHelper ()
  #8  0x03ac0f4b in v8::Object::SetInternalField ()
  #9  0x06a99ddd in node::ObjectWrap::~ObjectWrap ()
  #10 0x06a8b051 in node::Buffer::~Buffer ()
  #11 0x06a8afbb in node::Buffer::~Buffer ()
  #12 0x06a8af5e in node::Buffer::~Buffer ()
  #13 0x06a9e569 in node::ObjectWrap::WeakCallback ()
2013-04-10 15:37:30 +02:00
Ben Noordhuis 0d5595ac60 Revert "crypto: use better memory BIO implementation"
This change shouldn't have landed in the stable branch. It's a feature,
not a bug fix.

This reverts commit 58f93ffc4a.
This reverts commit 8c8ebe49b6.
This reverts commit ba0f7b8066.
This reverts commit 21f3c5c367.
2013-04-10 13:54:15 +02:00
Fedor Indutny c665b8e9ba net: fix socket.bytesWritten Buffers support
Buffer.byteLength() works only for string inputs. Thus, when connection
has pending Buffer to write, it should just use it's length instead of
throwing exception.
2013-04-10 14:51:10 +04:00
Ben Noordhuis eeb4c3216d crypto: remove unused ClientHelloParser field 2013-04-10 01:39:00 +02:00
isaacs 67096fdb38 blog: Post for v0.8.23 2013-04-08 17:41:49 -07:00
Łukasz Walukiewicz 2e28832660 buffer: fix offset checks
Fixed offset checks in Buffer.readInt32LE() and Buffer.readInt32BE()
functions.
2013-04-08 16:17:38 -07:00
isaacs c93af860a0 stream: call write cb before finish event
Since 049903e, an end callback could be called before a write
callback if end() is called before the write is done. This patch
resolves the issue.

In collaboration with @gne

Fixes felixge/node-formidable#209
Fixes #5215
2013-04-09 02:09:51 +04:00
isaacs e4b716efaa http: Support write(data, 'hex')
We were assuming that any string can be concatenated safely to
CRLF.  However, for hex, base64, or binary encoded writes, this
is not the case, and results in sending the incorrect response.

An unusual edge case, but certainly a bug.
2013-04-08 09:33:56 -07:00
Fedor Indutny 037bcac7ba crypto: dh secret should be left-padded
DH_compute_secret() may return key that is smaller than input buffer,
in such cases key should be left-padded because it is a BN (big number).

fix #5239
2013-04-08 19:45:35 +04:00
Rod Vagg ccabd4a6fa process: expose NODE_MODULE_VERSION in process.versions 2013-04-08 16:48:18 +02:00
Fedor Indutny 21f3c5c367 crypto: move write_head in bio's Reset() method 2013-04-08 15:53:25 +04:00
Fedor Indutny ba0f7b8066 crypto: fix changing buffers in bio
We should go to next buffer if *current* one is full, not the next one.
Otherwise we may hop through buffers and written data will become
interleaved, which will lead to failure.
2013-04-08 15:51:55 +04:00
Fedor Indutny 8c8ebe49b6 crypto: fix style issues in bio
Stop changing arguments, use local variables for things that change.
2013-04-08 15:51:51 +04:00
Andreas Madsen fed8cff1d0 crypto: fix constructor call in crypto streams
When using some stream method on a lazy crypto stream, the transform
constructor wasn't called. This caused the internal state object to
be undefined.
2013-04-08 14:45:42 +04:00
Fedor Indutny ff32ecd5bf net: account encoding in .byteLength 2013-04-08 11:48:46 +04:00
Ben Noordhuis e8c01739cd doc: document linux pwrite() bug
On Linux, positional writes don't work when the file is opened in
append mode. The kernel ignores the position argument and always
appends the data to the end of the file.

To quote the man page:

  POSIX requires that opening a file with the O_APPEND flag should have
  no affect on the location at which pwrite() writes data.  However, on
  Linux, if a file is opened with O_APPEND, pwrite() appends data to the
  end of the file, regardless of the value of offset.
2013-04-08 00:43:30 +02:00
Fedor Indutny eb39c9854a net: fix buffer iteration in bytesWritten 2013-04-08 01:17:40 +04:00