[feladat @ 294]
authorrejo
Sat, 12 Jul 2008 13:15:50 +0000
changeset 186 a3e83a34f267
parent 185 6baa2f78d3fe
child 187 ae77a8f97ee2
[feladat @ 294] Update of SRV record validation. Now checks for a maximum number of characters of content field and allows dash in first label of content field. Closes #45.
inc/dns.inc.php
--- a/inc/dns.inc.php	Fri Jul 11 08:59:07 2008 +0000
+++ b/inc/dns.inc.php	Sat Jul 12 13:15:50 2008 +0000
@@ -352,9 +352,15 @@
 }
 
 function is_valid_rr_srv_name($name){
+
+	if (strlen($name) > 255) {
+		error(ERR_DNS_HN_TOO_LONG);
+		return false;
+	}
+
 	$fields = explode('.', $name, 3);
-	if (!preg_match('/^_[a-z0-9]+$/i', $fields[0])) { error(ERR_DNS_SRV_NAME) ; return false; }
-	if (!preg_match('/^_[a-z0-9]+$/i', $fields[1])) { error(ERR_DNS_SRV_NAME) ; return false; }
+	if (!preg_match('/^_[\w-]+$/i', $fields[0])) { error(ERR_DNS_SRV_NAME) ; return false; }
+	if (!preg_match('/^_[\w]+$/i', $fields[1])) { error(ERR_DNS_SRV_NAME) ; return false; }
 	if (!is_valid_hostname_fqdn($fields[2],0)) { error(ERR_DNS_SRV_NAME) ; return false ; }
 	return true ;
 }