]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
logger: support sub-trees in the ID for RFC5424
authorKarel Zak <kzak@redhat.com>
Sat, 28 Jan 2017 11:39:52 +0000 (12:39 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 21 Feb 2017 12:12:43 +0000 (13:12 +0100)
The current code supports <name>@<digit> only, but we also need
<name>@<digit>.<digit>[. ...]

RFC5424: 7.2.2 enterpriseId:

 In general, only the IANA-assigned private enterprise number is
 needed (a single number).  An enterprise might decide to use
 sub-identifiers below its private enterprise number.  If sub-
 identifiers are used, they MUST be separated by periods and be
 represented as decimal numbers.  An example for that would be
 "32473.1.2".

Addresses: https://github.com/karelzak/util-linux/issues/406
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/logger.c

index 0e1ebfffcb11b77d4785e6df7a62ba6ca0ad28d7..67480c57d68a2140f329ddb26539fee9992ac1f3 100644 (file)
@@ -678,8 +678,19 @@ static int valid_structured_data_id(const char *str)
 
        if (!at || at == str || !*(at + 1))
                return 0;
-       if (!isdigit_string(at + 1))
-               return 0;
+
+       /* <digits> or <digits>.<digits>[...] */
+       for (p = at + 1; p && *p; p++) {
+               const char *end;
+
+               if (isdigit_strend(p, &end))
+                       break;  /* only digits in the string */
+
+               if (end == NULL || end == p ||
+                   *end != '.' || *(end + 1) == '\0')
+                       return 0;
+               p = end;
+       }
 
        /* check for forbidden chars in the <name> */
        for (p = str; p < at; p++) {