diff options
author | Antony Dovgal <tony2001@php.net> | 2007-01-15 17:07:08 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2007-01-15 17:07:08 +0000 |
commit | 7ad1c3c5f2fac4f22c2e7adc5b0b9d9a83f9a17e (patch) | |
tree | 3f8c73d5ed073b0bba5fad6c1c2b6dd374d3748c /main/streams/transports.c | |
parent | 7dd989fd4abf7782c423b8d990d13ff929141c68 (diff) | |
download | php-git-7ad1c3c5f2fac4f22c2e7adc5b0b9d9a83f9a17e.tar.gz |
MFH: add trailing '\0' to stream hashes
Diffstat (limited to 'main/streams/transports.c')
-rw-r--r-- | main/streams/transports.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/main/streams/transports.c b/main/streams/transports.c index 39dbea0f6a..54d0d9a9da 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -31,12 +31,12 @@ PHPAPI HashTable *php_stream_xport_get_hash(void) PHPAPI int php_stream_xport_register(char *protocol, php_stream_transport_factory factory TSRMLS_DC) { - return zend_hash_update(&xport_hash, protocol, strlen(protocol), &factory, sizeof(factory), NULL); + return zend_hash_update(&xport_hash, protocol, strlen(protocol) + 1, &factory, sizeof(factory), NULL); } PHPAPI int php_stream_xport_unregister(char *protocol TSRMLS_DC) { - return zend_hash_del(&xport_hash, protocol, strlen(protocol)); + return zend_hash_del(&xport_hash, protocol, strlen(protocol) + 1); } #define ERR_REPORT(out_err, fmt, arg) \ @@ -106,7 +106,8 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int } if (protocol) { - if (FAILURE == zend_hash_find(&xport_hash, (char*)protocol, n, (void**)&factory)) { + char *tmp = estrndup(protocol, n); + if (FAILURE == zend_hash_find(&xport_hash, (char*)tmp, n + 1, (void**)&factory)) { char wrapper_name[32]; if (n >= sizeof(wrapper_name)) @@ -116,8 +117,10 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int ERR_REPORT(error_string, "Unable to find the socket transport \"%s\" - did you forget to enable it when you configured PHP?", wrapper_name); + efree(tmp); return NULL; } + efree(tmp); } if (factory == NULL) { |