Skip to content

Instantly share code, notes, and snippets.

View bnoordhuis's full-sized avatar

Ben Noordhuis bnoordhuis

View GitHub Profile
@bnoordhuis
bnoordhuis / un.c
Created February 8, 2014 12:01
PoC of OS X sockaddr_un system crash
// Crashes OS X 10.8, `cc un.c && while :; do ./a.out ; done` to run.
// The buffer overflow usually gets triggered within the first three
// or four runs. Make sure you back up your data first!
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
// scons mode=debug arch=x64
// g++ -m64 -Wall -ggdb stack-guard.cc -Iinclude libv8_g.a -lpthread && ./a.out; echo "$?"
//
// gcc version 4.4.5 (Debian 4.4.5-8)
// http://v8.googlecode.com/svn/trunk@r6858
//
// Repros on x64, does not repro in ia32
#include "v8.h"
#include <iostream>
#include <assert.h>
@bnoordhuis
bnoordhuis / dummy.cc
Created August 5, 2010 20:46
Reproduce SIGSEGV in Buffer::New(size_t)
#include <v8.h>
#include <node.h>
#include <alloca.h>
#include <node_buffer.h>
using namespace v8;
using namespace node;
static Handle<Value> dummy(const Arguments& args) {
HandleScope scope;
### fs.utimes(path, atime, mtime, [callback])
Asynchronous utimes(2). Updates the last access and last modified timestamps of
the file pointed to by `path`.
`atime` and `mtime` may be a (fractional) UNIX timestamp or a Date object.
No arguments other than a possible exception are given to the completion callback.
### fs.futimes(fd, atime, mtime, [callback])
@bnoordhuis
bnoordhuis / gist:658726
Created November 1, 2010 19:36
0001-Fix-undefined-symbol-errors-when-loading-native-modu.patch
From 360b7b57b2e0261f6ba84f023fdc31f4f6e514f2 Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Mon, 1 Nov 2010 20:34:11 +0100
Subject: [PATCH] Fix 'undefined symbol' errors when loading native modules.
---
Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
@bnoordhuis
bnoordhuis / gist:664983
Created November 5, 2010 22:30
0001-Ensure-that-non-ASCII-characters-in-the-status-line-.patch
From 1ee950ffaccdf61c102b11990a07a22038a1ec7a Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Fri, 5 Nov 2010 23:27:55 +0100
Subject: [PATCH] Ensure that non-ASCII characters in the status line are allowed.
---
test.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/test.c b/test.c
@bnoordhuis
bnoordhuis / gist:667592
Created November 8, 2010 11:07
0001-Backport-base64-encoder-decoder-changes-from-master-.patch
From 047a5e55a0ec54ff517fb2f0f6eac426e26f4127 Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Mon, 8 Nov 2010 11:57:47 +0100
Subject: [PATCH] Backport base64 encoder/decoder changes from master to v0.2.
---
src/node_buffer.cc | 78 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 55 insertions(+), 23 deletions(-)
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
@bnoordhuis
bnoordhuis / gist:673377
Created November 11, 2010 22:50
readsync-busy-loop.js
//
// test case: fs.readSync() eventually starts busy-looping in C++ land
//
// create a writer with `while true; do date >> /tmp/time.log; sleep 1; done`
// then run `node tail.js /tmp/time.log`
//
Buffer = require('buffer').Buffer;
fs = require('fs');
b = new Buffer(256);
@bnoordhuis
bnoordhuis / gist:702701
Created November 16, 2010 23:05
Server.listen() doesn't listen (to me)
s = require('http').createServer(function(req, res) {
res.writeHead(200, {'Content-Length':0});
res.end();
});
s.listen(8080);
@bnoordhuis
bnoordhuis / gist:709310
Created November 21, 2010 23:58
request.js
http = require('http');
client = http.createClient(80, 'www.google.com');
req = client.request('POST', '/', {'Content-Type':'application/x-www-form-urlencoded'});
req.on('response', console.log);
req.end();