diff options
author | normalperson <normalperson@19e92222-5c0b-0410-8929-a290d50e31e9> | 2008-03-06 07:41:33 +0000 |
---|---|---|
committer | normalperson <normalperson@19e92222-5c0b-0410-8929-a290d50e31e9> | 2008-03-06 07:41:33 +0000 |
commit | 2289acf852fae97d0484304870495b8fc15f752e (patch) | |
tree | 1e00475800c4c87e1d7e118bb44850d6dbb1b867 /ext/http11/http11.c | |
parent | a9ab034e62dbe5740cc1b353aed2320646606c73 (diff) | |
download | unicorn-2289acf852fae97d0484304870495b8fc15f752e.tar.gz |
Replace it with memchr(3) instead, which works on a buffer with a predetermined length, so we don't have to worry about strange versions of Ruby which don't null-terminate strings. memchr() is used several times in the MRI source code itself (without compatibility definitions), so it should be portable to all platforms MRI runs on. Additionally, we now tolerate null bytes in the Host header and can still parse ports in them correctly if anybody sends them :) If it matters, it is also theoretically faster as it doesn't need to check for a '\0' terminator. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@993 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'ext/http11/http11.c')
-rw-r--r-- | ext/http11/http11.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/ext/http11/http11.c b/ext/http11/http11.c index 5af1e8c..e0feece 100644 --- a/ext/http11/http11.c +++ b/ext/http11/http11.c @@ -292,8 +292,7 @@ void header_done(void *data, const char *at, size_t length) rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value); if((temp = rb_hash_aref(req, global_http_host)) != Qnil) { - /* ruby better close strings off with a '\0' dammit */ - colon = strchr(RSTRING_PTR(temp), ':'); + colon = memchr(RSTRING_PTR(temp), ':', RSTRING_LEN(temp)); if(colon != NULL) { rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp))); rb_hash_aset(req, global_server_port, |