-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Trap exceptions in URIParser.
A user was able to crash chat.tinyclouds.org by sending it a malformed URL! Not good.
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
include("mjsunit.js"); | ||
|
||
// Make sure no exceptions are thrown when receiving malformed HTTP | ||
// requests. | ||
port = 9999; | ||
|
||
nrequests_completed = 0; | ||
nrequests_expected = 1; | ||
|
||
var s = node.http.createServer(function (req, res) { | ||
puts("req: " + JSON.stringify(req.uri)); | ||
|
||
res.sendHeader(200, {"Content-Type": "text/plain"}); | ||
res.sendBody("Hello World"); | ||
res.finish(); | ||
|
||
if (++nrequests_completed == nrequests_expected) s.close(); | ||
}); | ||
s.listen(port); | ||
|
||
var c = node.tcp.createConnection(port); | ||
c.addListener("connect", function () { | ||
c.send("GET /hello?foo=%99bar HTTP/1.1\r\n\r\n"); | ||
c.close(); | ||
}); | ||
|
||
// TODO add more! | ||
|
||
process.addListener("exit", function () { | ||
assertEquals(nrequests_expected, nrequests_completed); | ||
}); |