summaryrefslogtreecommitdiff
path: root/src/basic/syslog-util.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-12-21 22:06:22 +0100
committerMichael Biebl <biebl@debian.org>2018-12-21 22:06:22 +0100
commit6e866b331d7cd4a5e0759dd160dea6edabd3678e (patch)
tree4d24c1ffe4ae946f04d8910956090e8d13aecd9a /src/basic/syslog-util.c
parentb012e92123bdc9fa10c2f079ec5bd9313b23e21a (diff)
downloadsystemd-6e866b331d7cd4a5e0759dd160dea6edabd3678e.tar.gz
New upstream version 240
Diffstat (limited to 'src/basic/syslog-util.c')
-rw-r--r--src/basic/syslog-util.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/basic/syslog-util.c b/src/basic/syslog-util.c
index 21461fa581..fe129482f3 100644
--- a/src/basic/syslog-util.c
+++ b/src/basic/syslog-util.c
@@ -10,7 +10,8 @@
int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
int a = 0, b = 0, c = 0;
- int k;
+ const char *end;
+ size_t k;
assert(p);
assert(*p);
@@ -19,21 +20,22 @@ int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
if ((*p)[0] != '<')
return 0;
- if (!strchr(*p, '>'))
+ end = strchr(*p, '>');
+ if (!end)
return 0;
- if ((*p)[2] == '>') {
+ k = end - *p;
+ assert(k > 0);
+
+ if (k == 2)
c = undecchar((*p)[1]);
- k = 3;
- } else if ((*p)[3] == '>') {
+ else if (k == 3) {
b = undecchar((*p)[1]);
c = undecchar((*p)[2]);
- k = 4;
- } else if ((*p)[4] == '>') {
+ } else if (k == 4) {
a = undecchar((*p)[1]);
b = undecchar((*p)[2]);
c = undecchar((*p)[3]);
- k = 5;
} else
return 0;
@@ -46,7 +48,7 @@ int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
else
*priority = (*priority & LOG_FACMASK) | c;
- *p += k;
+ *p += k + 1;
return 1;
}