Don't try to parse a NULL ip address for boot server

The boot server IP address is optional, so it needs to be
checked before attempting to parse it.

* src/conf/network_conf.c: Don't parse NULL ip address for
  boot server
This commit is contained in:
Daniel P. Berrange 2010-10-22 13:28:04 +01:00
parent 090404acfe
commit 4af718297a
1 changed files with 3 additions and 1 deletions

View File

@ -317,6 +317,7 @@ virNetworkDHCPRangeDefParseXML(virNetworkDefPtr def,
xmlChar *file;
xmlChar *server;
virSocketAddr inaddr;
memset(&inaddr, 0, sizeof(inaddr));
if (!(file = xmlGetProp(cur, BAD_CAST "file"))) {
cur = cur->next;
@ -324,7 +325,8 @@ virNetworkDHCPRangeDefParseXML(virNetworkDefPtr def,
}
server = xmlGetProp(cur, BAD_CAST "server");
if (virSocketParseAddr((const char *)server, &inaddr, AF_UNSPEC) < 0)
if (server &&
virSocketParseAddr((const char *)server, &inaddr, AF_UNSPEC) < 0)
return -1;
def->bootfile = (char *)file;