cvs: php4 /ext/ircg ircg.c

From: Date: Tue, 31 Jul 2001 17:46:53 +0000
Subject: cvs: php4 /ext/ircg ircg.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6443@lists.php.net to get a copy of this message
sas Tue Jul 31 13:46:53 2001 EDT Modified files: /php4/ext/ircg ircg.c Log: Fix two potential crash bugs. 1. if no valid format message identifier was provided. 2. if result string was empty in format_msg() Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.94 php4/ext/ircg/ircg.c:1.95 --- php4/ext/ircg/ircg.c:1.94 Tue Jul 31 02:28:03 2001 +++ php4/ext/ircg/ircg.c Tue Jul 31 13:46:52 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.94 2001/07/31 06:28:03 zeev Exp $ */ +/* $Id: ircg.c,v 1.95 2001/07/31 17:46:52 sas Exp $ */ #include <time.h> @@ -162,6 +162,8 @@ P_MIRC_JS = 5 }; +static php_fmt_msgs_t fmt_msgs_default_compiled; + static char *fmt_msgs_default[] = { "%f@%c: %m<br />", "%f: %m<br />", @@ -530,7 +532,8 @@ if (encoded) smart_str_free_ex(&encoded_msg, 1); - smart_str_0(result); + if (result->c) + smart_str_0(result); } /* }}} */ @@ -572,9 +575,8 @@ break; default: #if defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010601 -#warning ok if (irc_write_buf_append_ex(&conn->wb, msg, 0)) { - irc_disconnect(&conn->conn, "Broken connection"); + irc_disconnect(&conn->conn, "Write to HTTP client failed"); } #elif defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010302 irc_write_buf_append_ex(&conn->wb, msg, 0); @@ -1504,6 +1506,9 @@ username = Z_STRVAL_PP(p1); } + if (!fmt_msgs) + fmt_msgs = &fmt_msgs_default_compiled; + /* * conn must be able to live longer than the hash entry in h_irconn, * so we have to allocate it ourselves. @@ -1707,6 +1712,8 @@ */ PHP_MINIT_FUNCTION(ircg) { + int i; + #if IRCG_API_VERSION >= 20010307 if (irc_sizeof_irconn() != sizeof(irconn_t)) { printf("FATAL: The size of the irconn_t structure has changed " @@ -1722,6 +1729,10 @@ exit(1); } #endif + + for (i = 0; i < NO_FMTS; i++) { + token_compiler(fmt_msgs_default[i], &fmt_msgs_default_compiled.fmt_msgs[i]); + } zend_hash_init(&h_fmt_msgs, 0, NULL, fmt_msgs_dtor, 1); zend_hash_init(&h_fd2irconn, 0, NULL, NULL, 1);

« previous php.cvs (#6443) next »