[PATCH] Fix to dns_get_record

From: Date: Fri, 22 Nov 2002 22:50:02 +0000
Subject: [PATCH] Fix to dns_get_record
Groups: php.dev 
Request: Send a blank email to php-dev+get-91467@lists.php.net to get a copy of this message
Thanks for your modifications to dns_get_record Marcus, but an extra change or two needs to be throw in to get it working just right. Here's a tiny patch to avoid inserting random values as subarrays (leading to a segfault) and properly dispose of resolv resources between queries. Trouble is, the function as I had it WOULDN'T get unexpected records (see "this shouldn't happen" comment), but your changes made that a possibility and allowed php_parserr to return without ever properly setting *subarray. It dosen't help that the "unexpected" condition wasn't dealing with it's potentiality right to begin with... :) -Pollita Index: dns.c =================================================================== RCS file: /repository/php4/ext/standard/dns.c,v retrieving revision 1.45 diff -u -r1.45 dns.c --- dns.c 19 Nov 2002 02:34:13 -0000 1.45 +++ dns.c 22 Nov 2002 22:14:34 -0000 @@ -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); } }

Index: dns.c =================================================================== RCS file: /repository/php4/ext/standard/dns.c,v retrieving revision 1.45 diff -u -r1.45 dns.c --- dns.c 19 Nov 2002 02:34:13 -0000 1.45 +++ dns.c 22 Nov 2002 22:14:34 -0000 @@ -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); } }
« previous php.dev (#91467) next »