[PHP-CVS] cvs: php4 /ext/standard dns.c
sniper Thu Feb 20 00:34:58 2003 EDT Modified files: /php4/ext/standard dns.c Log: - Fixed bug #22299 (gethostbyname() crash with non-existing domain on MacOSX) Index: php4/ext/standard/dns.c diff -u php4/ext/standard/dns.c:1.54 php4/ext/standard/dns.c:1.55 --- php4/ext/standard/dns.c:1.54Sat Feb 15 22:48:47 2003 +++ php4/ext/standard/dns.c Thu Feb 20 00:34:58 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: dns.c,v 1.54 2003/02/16 03:48:47 wez Exp $ */ +/* $Id: dns.c,v 1.55 2003/02/20 05:34:58 sniper Exp $ */ /* {{{ includes */ #include php.h @@ -195,7 +195,7 @@ hp = gethostbyname(name); - if (!hp || !hp-h_addr_list) { + if (!hp || !*(hp-h_addr_list)) { return estrdup(name); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/standard dns.c
helly Mon Dec 30 06:59:22 2002 EDT Modified files: /php4/ext/standard dns.c Log: fix state-machine in cases T_ is not available Index: php4/ext/standard/dns.c diff -u php4/ext/standard/dns.c:1.51 php4/ext/standard/dns.c:1.52 --- php4/ext/standard/dns.c:1.51Fri Dec 20 13:34:56 2002 +++ php4/ext/standard/dns.c Mon Dec 30 06:59:22 2002 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: dns.c,v 1.51 2002/12/20 18:34:56 pollita Exp $ */ +/* $Id: dns.c,v 1.52 2002/12/30 11:59:22 helly Exp $ */ /* {{{ includes */ #include php.h @@ -548,10 +548,12 @@ case 7: type_to_fetch = type_paramPHP_DNS_TXT ? T_TXT : 0; break; -#ifdef T_ case 8: +#ifdef T_ type_to_fetch = type_paramPHP_DNS_ ? T_ : 0; break; +#else + continue; #endif case 9: store_results = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 /ext/standard dns.c
Instead of: #ifdef T_ /* blah blah blah */ #endif Why not just put: #ifndef T_ #define T_ 28 #endif in dns.h? This should let the function continue working even on platforms where T_ isn't defined? WHere do you get those numbers? Are you sure they are correct? Anywya, I think the solution Jani introduced is better, now we dont enable code if it's not available on a platform. RFC 1886 - Section 2.1 http://www.ietf.org/rfc/rfc1886.txt libresolv (and I should imagine other resolver libraries) simply pass these numbers through to the question section of the dns query packet. (See RFC 1035) Therefore it's reasonable to assume that if the resolver library supports dns queries at all (i.e. T_A, T_NS, T_CNAME, etc...) that it would have to support any types since it's just another 16-bit big-endian integer being included in the packet. While it's true that Jani's solution will avoid enabling code on platforms where it's not supported, it'll also unnecessarily disable functionality on platforms which would otherwise support it. -Pollita -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 /ext/standard dns.c
On Thu, 12 Dec 2002, Sara Golemon wrote: Bug #17174 Added IPv6 ( record) support to dns_check_record() also added support to dns_get_record This might break builds on some platforms, as T_ is not always defined. See the comment in bug #19555. Heh..I should read PHP-CVS folder first.. :) Anyway, I just committed a fix for that prob. Instead of: #ifdef T_ /* blah blah blah */ #endif Why not just put: #ifndef T_ #define T_ 28 #endif in dns.h? This should let the function continue working even on platforms where T_ isn't defined? WHere do you get those numbers? Are you sure they are correct? Anywya, I think the solution Jani introduced is better, now we dont enable code if it's not available on a platform. Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 /ext/standard dns.c
On Sun, 8 Dec 2002, Sara Golemon wrote: pollita Sun Dec 8 03:14:43 2002 EDT Modified files: /php4/ext/standarddns.c Log: Bug #17174 Added IPv6 ( record) support to dns_check_record() also added support to dns_get_record This might break builds on some platforms, as T_ is not always defined. See the comment in bug #19555. Derick -- - Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ - -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/standard dns.c
pollita Sun Dec 8 03:14:43 2002 EDT Modified files: /php4/ext/standard dns.c Log: Bug #17174 Added IPv6 ( record) support to dns_check_record() also added support to dns_get_record Index: php4/ext/standard/dns.c diff -u php4/ext/standard/dns.c:1.47 php4/ext/standard/dns.c:1.48 --- php4/ext/standard/dns.c:1.47Thu Dec 5 17:28:02 2002 +++ php4/ext/standard/dns.c Sun Dec 8 03:14:43 2002 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: dns.c,v 1.47 2002/12/05 22:28:02 iliaa Exp $ */ +/* $Id: dns.c,v 1.48 2002/12/08 08:14:43 pollita Exp $ */ /* {{{ includes */ #include php.h @@ -241,6 +241,7 @@ else if (!strcasecmp(ANY, Z_STRVAL_PP(arg2))) type = T_ANY; else if (!strcasecmp(SOA, Z_STRVAL_PP(arg2))) type = T_SOA; else if (!strcasecmp(CNAME, Z_STRVAL_PP(arg2))) type = T_CNAME; + else if (!strcasecmp(, Z_STRVAL_PP(arg2))) type = +T_; else { php_error_docref(NULL TSRMLS_CC, E_WARNING, Type '%s' not supported, Z_STRVAL_PP(arg2)); RETURN_FALSE; @@ -272,9 +273,9 @@ #define PHP_DNS_HINFO 0x1000 #define PHP_DNS_MX 0x4000 #define PHP_DNS_TXT0x8000 - +#define PHP_DNS_ 0x0800 #define PHP_DNS_ANY0x1000 -#define PHP_DNS_ALL (PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_MX|PHP_DNS_TXT) +#define PHP_DNS_ALL +(PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_) PHP_MINIT_FUNCTION(dns) { REGISTER_LONG_CONSTANT(DNS_A, PHP_DNS_A, CONST_CS | CONST_PERSISTENT); @@ -285,6 +286,7 @@ REGISTER_LONG_CONSTANT(DNS_HINFO, PHP_DNS_HINFO, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(DNS_MX,PHP_DNS_MX,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(DNS_TXT, PHP_DNS_TXT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(DNS_, PHP_DNS_, CONST_CS | +CONST_PERSISTENT); REGISTER_LONG_CONSTANT(DNS_ANY, PHP_DNS_ANY, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(DNS_ALL, PHP_DNS_ALL, CONST_CS | CONST_PERSISTENT); return SUCCESS; @@ -316,6 +318,8 @@ u_short type, class, dlen; u_long ttl; long n, i; + u_short s; + u_char *tp; char name[MAXHOSTNAMELEN]; n = dn_expand(answer-qb2, answer-qb2+65536, cp, name, (sizeof(name)) - 2); @@ -416,6 +420,30 @@ GETLONG(n, cp); add_assoc_long(*subarray, minimum-ttl, n); break; + case T_: + tp = name; + for(i=0; i 8; i++) { + GETSHORT(s, cp); + if (s 0) { + if (tp (u_char *)name) { + tp[0] = ':'; + tp++; + } + sprintf(tp,%x,s); + tp += strlen(tp); + } else if (s == 0) { + if ((tp (u_char *)name) (tp[-1] != ':')) { + tp[0] = ':'; + tp++; + } + } + } + if ((tp (u_char *)name) (tp[-1] == ':')) + tp[-1] = '\0'; + tp[0] = '\0'; + add_assoc_string(*subarray, type, , 1); + add_assoc_string(*subarray, ipv6, name, 1); + break; default: cp += dlen; } @@ -480,13 +508,13 @@ /* Initialize the return array */ array_init(return_value); - /* - We emulate an or'ed type mask by querying type by type. (Steps 0 - 7) -* If additional info is wanted we check again with T_ANY (step 8/9) + /* - We emulate an or'ed type mask by querying type by type. (Steps 0 - 8) +* If additional info is wanted we check again with T_ANY (step 9/10) * store_results is used to skip storing the results retrieved in step -* 9 when results were already fetched. -* - In case of PHP_DNS_ANY we use the directly fetch T_ANY. (step 9) +* 10 when results were already fetched. +* - In case of PHP_DNS_ANY we use the directly fetch T_ANY. (step 10) */ - for(type = (type_param==PHP_DNS_ANY ? 9 : 0); type (addtl_recs ? 10 : 8) || first_query;
[PHP-CVS] cvs: php4 /ext/standard dns.c
moriyoshi Sun Dec 8 04:54:31 2002 EDT Modified files: /php4/ext/standard dns.c Log: Prevented return_value from being freed() twice Index: php4/ext/standard/dns.c diff -u php4/ext/standard/dns.c:1.48 php4/ext/standard/dns.c:1.49 --- php4/ext/standard/dns.c:1.48Sun Dec 8 03:14:43 2002 +++ php4/ext/standard/dns.c Sun Dec 8 04:54:30 2002 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: dns.c,v 1.48 2002/12/08 08:14:43 pollita Exp $ */ +/* $Id: dns.c,v 1.49 2002/12/08 09:54:30 moriyoshi Exp $ */ /* {{{ includes */ #include php.h @@ -561,13 +561,13 @@ n = res_nmkquery(res, QUERY, Z_STRVAL_P(host), C_IN, type_to_fetch, NULL, 0, NULL, buf.qb2, sizeof buf); if (n0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, res_nmkquery() failed); - zval_ptr_dtor(return_value); + zval_dtor(return_value); RETURN_FALSE; } n = res_nsend(res, buf.qb2, n, answer.qb2, sizeof answer); if (n0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, res_nsend() failed); - zval_ptr_dtor(return_value); + zval_dtor(return_value); RETURN_FALSE; } @@ -585,7 +585,7 @@ n = dn_skipname(cp, end); if (n 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to parse DNS data received); - zval_ptr_dtor(return_value); + zval_dtor(return_value); RETURN_FALSE; } cp += n + QFIXEDSZ; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/standard dns.c
pollita Fri Nov 22 20:09:08 2002 EDT Modified files: /php4/ext/standard dns.c Log: New function dns_get_record(): close resolver socket after use. fix to internal func php_parserr(): correct bug in return state. Index: php4/ext/standard/dns.c diff -u php4/ext/standard/dns.c:1.45 php4/ext/standard/dns.c:1.46 --- php4/ext/standard/dns.c:1.45Mon Nov 18 21:34:13 2002 +++ php4/ext/standard/dns.c Fri Nov 22 20:09:07 2002 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: dns.c,v 1.45 2002/11/19 02:34:13 helly Exp $ */ +/* $Id: dns.c,v 1.46 2002/11/23 01:09:07 pollita Exp $ */ /* {{{ includes */ #include php.h @@ -331,8 +331,9 @@ GETLONG(ttl, cp); GETSHORT(dlen, cp); if (type_to_fetch != T_ANY type != type_to_fetch) { - /* Should never actually occour */ - return NULL; + *subarray = NULL; + cp += dlen; + return cp; } if (!store) { @@ -576,6 +577,7 @@ zend_hash_next_index_insert(HASH_OF(return_value), (void *)subarray[current_subarray], sizeof(zval *), NULL); current_subarray++; } + res_nclose(res); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/standard dns.c
sniper Fri Oct 18 18:08:23 2002 EDT Modified files: /php4/ext/standard dns.c Log: ws fixes Index: php4/ext/standard/dns.c diff -u php4/ext/standard/dns.c:1.43 php4/ext/standard/dns.c:1.44 --- php4/ext/standard/dns.c:1.43Thu Sep 5 10:21:55 2002 +++ php4/ext/standard/dns.c Fri Oct 18 18:08:23 2002 -16,21 +16,24 +--+ */ -/* $Id: dns.c,v 1.43 2002/09/05 14:21:55 hyanantha Exp $ */ +/* $Id: dns.c,v 1.44 2002/10/18 22:08:23 sniper Exp $ */ /* {{{ includes */ + #include php.h + #if HAVE_SYS_SOCKET_H #include sys/socket.h #endif + #ifdef PHP_WIN32 #if HAVE_LIBBIND #ifndef WINNT #define WINNT 1 #endif /* located in www.php.net/extra/bindlib.zip */ -#if HAVE_ARPA_INET_H +#if HAVE_ARPA_INET_H #include arpa/inet.h #endif #include netdb.h -40,7 +43,7 #if HAVE_RESOLV_H #include resolv.h #endif -#endif +#endif /* HAVE_LIBBIND */ #include winsock.h #else /* This holds good for NetWare too, both for Winsock and Berkeley sockets */ #include netinet/in.h -220,38 +223,44 u_char ans[MAXPACKET]; switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, arg1) == FAILURE) { - WRONG_PARAM_COUNT; - } - type = T_MX; - convert_to_string_ex(arg1); - break; - case 2: - if (zend_get_parameters_ex(2, arg1, arg2) == FAILURE) { + case 1: + if (zend_get_parameters_ex(1, arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + type = T_MX; + convert_to_string_ex(arg1); + break; + + case 2: + if (zend_get_parameters_ex(2, arg1, arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(arg1); + convert_to_string_ex(arg2); + + if (!strcasecmp(A, Z_STRVAL_PP(arg2))) type = T_A; + else if (!strcasecmp(NS,Z_STRVAL_PP(arg2))) type = T_NS; + else if (!strcasecmp(MX,Z_STRVAL_PP(arg2))) type = T_MX; + else if (!strcasecmp(PTR, Z_STRVAL_PP(arg2))) type = T_PTR; + else if (!strcasecmp(ANY, Z_STRVAL_PP(arg2))) type = T_ANY; + else if (!strcasecmp(SOA, Z_STRVAL_PP(arg2))) type = T_SOA; + else if (!strcasecmp(CNAME, Z_STRVAL_PP(arg2))) type = +T_CNAME; + else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Type '%s' +not supported, Z_STRVAL_PP(arg2)); + RETURN_FALSE; + } + break; + + default: WRONG_PARAM_COUNT; - } - convert_to_string_ex(arg1); - convert_to_string_ex(arg2); - if ( !strcasecmp(A, Z_STRVAL_PP(arg2)) ) type = T_A; - else if ( !strcasecmp(NS, Z_STRVAL_PP(arg2)) ) type = T_NS; - else if ( !strcasecmp(MX, Z_STRVAL_PP(arg2)) ) type = T_MX; - else if ( !strcasecmp(PTR, Z_STRVAL_PP(arg2)) ) type = T_PTR; - else if ( !strcasecmp(ANY, Z_STRVAL_PP(arg2)) ) type = T_ANY; - else if ( !strcasecmp(SOA, Z_STRVAL_PP(arg2)) ) type = T_SOA; - else if ( !strcasecmp(CNAME, Z_STRVAL_PP(arg2)) ) type = T_CNAME; - else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Type '%s' not supported, Z_STRVAL_PP(arg2)); - RETURN_FALSE; - } - break; - default: - WRONG_PARAM_COUNT; } + i = res_search(Z_STRVAL_PP(arg1), C_IN, type, ans, sizeof(ans)); - if ( i 0 ) { + + if (i 0) { RETURN_FALSE; } + RETURN_TRUE; } /* }}} */ -283,65 +292,69 int i; switch(ZEND_NUM_ARGS()) { - case 2: - if (zend_get_parameters(ht, 2, host, mx_list) == FAILURE) { - WRONG_PARAM_COUNT; - } -break; -case 3: - if (zend_get_parameters(ht, 3, host, mx_list, weight_list) == FAILURE) { + case 2: + if (zend_get_parameters(ht, 2, host, mx_list) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + + case 3: + if (zend_get_parameters(ht, 3, host, mx_list, weight_list) +== FAILURE) { + WRONG_PARAM_COUNT; + } + need_weight = 1; +