Project

General

Profile

« Previous | Next » 

Revision 1fb8d314

Added by Ermal LUÇI almost 14 years ago

Prevent php from coring if the wrong parameters are passed to ip2long

View differences:

etc/inc/filter.inc
1402 1402
		}
1403 1403
		/* PPTP subnet */
1404 1404
		if(($config['pptpd']['mode'] == "server" ) && is_private_ip($config['pptpd']['remoteip'])) {
1405
			$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip'])+($config['pptpd']['n_pptp_units']-1)));
1405
			if (isset($config['pptpd']['n_pptp_units']) && is_numeric($config['pptpd']['n_pptp_units']))
1406
				$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip'])+($config['pptpd']['n_pptp_units']-1)));
1407
			else
1408
				$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip'])));
1406 1409
			$numberofnathosts += count($pptp_subnets);
1407 1410
			$tonathosts .= implode(" ", $pptp_subnets) . " ";
1408 1411
		}
......
1765 1768
						$src = "{$lansa}/{$lansn}";
1766 1769
						break;
1767 1770
					case 'pptp':
1768
						$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip'])+($config['pptpd']['n_pptp_units']-1)));
1771
						if (isset($config['pptpd']['n_pptp_units']) && is_numeric($config['pptpd']['n_pptp_units']))
1772
							$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip'])+($config['pptpd']['n_pptp_units']-1)));
1773
						else
1774
							$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip'])));
1775
						if (empty($pptp_subnets))
1776
							return "";
1769 1777
						$src = "{ " . implode(" ", $pptp_subnets) . " }";
1770
						$src = "{$pptpsa}/{$pptpsn}";
1771 1778
						break;
1772 1779
					case 'pppoe':
1773 1780
						/* XXX: This needs to be fixed somehow! */
etc/inc/vpn.inc
1036 1036
		unlink_if_exists("{$g['varetc_path']}/pptp-vpn/mpd.secret");
1037 1037
	}
1038 1038

  
1039
	if (empty($pptpdcfg['n_pptp_units'])) {
1040
		log_error("Something wrong in the PPTPd configuration. Preventing starting the daemon because issues would arise.");
1041
		return; 
1042
	}
1043

  
1039 1044
	/* make sure pptp-vpn directory exists */
1040 1045
	if (!file_exists("{$g['varetc_path']}/pptp-vpn"))
1041 1046
		mkdir("{$g['varetc_path']}/pptp-vpn");

Also available in: Unified diff