summaryrefslogtreecommitdiffstats
path: root/misc-utils/logger.c
diff options
context:
space:
mode:
authorKarel Zak2017-01-28 12:39:52 +0100
committerKarel Zak2017-01-28 12:39:52 +0100
commit6d8a31f6db4006c6b9750b6381d0bd74ffc992c6 (patch)
treed72d4ab849b2fe0d7490bd716b179d22d6558675 /misc-utils/logger.c
parentlib/strutils: return end pointer by isdigit_string() (diff)
downloadkernel-qcow2-util-linux-6d8a31f6db4006c6b9750b6381d0bd74ffc992c6.tar.gz
kernel-qcow2-util-linux-6d8a31f6db4006c6b9750b6381d0bd74ffc992c6.tar.xz
kernel-qcow2-util-linux-6d8a31f6db4006c6b9750b6381d0bd74ffc992c6.zip
logger: support sub-trees in the ID for RFC5424
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>
Diffstat (limited to 'misc-utils/logger.c')
-rw-r--r--misc-utils/logger.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 8111a927e..b9fcc8552 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;
+
+ /* <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++) {