From: Karel Zak Date: Sat, 28 Jan 2017 11:39:52 +0000 (+0100) Subject: logger: support sub-trees in the ID for RFC5424 X-Git-Tag: v2.29.2~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e6fa51616863d5675ff3bcae995ce61cc18e11c;p=thirdparty%2Futil-linux.git logger: support sub-trees in the ID for RFC5424 The current code supports @ only, but we also need @.[. ...] 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 --- diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 0e1ebfffcb..67480c57d6 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -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; + + /* or .[...] */ + 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 */ for (p = str; p < at; p++) {