[PATCH] conf: network: Allow hostnames to start with a number

Peter Krempa posted 1 patch 2 years, 2 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/673b74be5fda928da5e9f3c2cfbf6c1cb1eda0c6.1643122118.git.pkrempa@redhat.com
src/conf/network_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] conf: network: Allow hostnames to start with a number
Posted by Peter Krempa 2 years, 2 months ago
From: Nicolas Lécureuil <neoclust@mageia.org>

RFC952 mandated that hostnames would start with an alpha character.
This requirement was later relaxed by RFC1123 which allowed hostnames to
start with a number as well.

https://datatracker.ietf.org/doc/html/rfc952
https://datatracker.ietf.org/doc/html/rfc1123#page-13

Signed-off-by: Nicolas Lécureuil <nicolas.lecureuil@siveo.net>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
---

Pushed after review of a trivial merge request.

 src/conf/network_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 10d3330fdf..c769bbaeb5 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -548,7 +548,7 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
     }

     name = virXMLPropString(node, "name");
-    if (name && (!g_ascii_isalpha(name[0]))) {
+    if (name && !(g_ascii_isalpha(name[0]) || g_ascii_isdigit(name[0]))) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("Cannot use host name '%s' in network '%s'"),
                        name, networkName);
-- 
2.34.1