From b2e83c7cc13d52b1047814ba55fc75e981231e25 Mon Sep 17 00:00:00 2001 From: mxi1 Date: Tue, 21 Jul 2009 06:48:40 +0000 Subject: [PATCH] -defect 2817258 is fixed; add the check point for inet_ntoa git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3840 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/dhcp.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 3d9441cbb..1c71793c3 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -135,7 +135,17 @@ sub addnode $nrent = $nrhash->{$node}->[0]; if ($nrent and $nrent->{tftpserver}) { - $tftpserver = inet_ntoa(inet_aton($nrent->{tftpserver})); + #check the value of inet_ntoa(inet_aton("")),if the hostname cannot be resolved, + #the value of inet_ntoa() will be "undef", which will cause fatal error + my $tmp_name = inet_aton($nrent->{tftpserver}); + unless($tmp_name) { + #tell the reason to the user + $callback->( + { error => ["Unable to resolve the tftpserver for node"], errorcode => [1]} + ); + return; + } + $tftpserver = inet_ntoa($tmp_name); $lstatements = 'next-server ' . $tftpserver . ';'