mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-09 23:34:51 +01:00
fluent-bit: fix kmsg plugin issues
* improved type conversion * improved error checking while string parsing * misc improvements
This commit is contained in:
parent
bce9364d14
commit
f5715d478a
1 changed files with 73 additions and 0 deletions
73
fluent-bit/patches/0020-fix_kmsg.patch
Normal file
73
fluent-bit/patches/0020-fix_kmsg.patch
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
diff --git a/plugins/in_kmsg/in_kmsg.c b/plugins/in_kmsg/in_kmsg.c
|
||||
index cd5c4cd17..15f105451 100644
|
||||
--- a/plugins/in_kmsg/in_kmsg.c
|
||||
+++ b/plugins/in_kmsg/in_kmsg.c
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <inttypes.h>
|
||||
-#include <time.h>
|
||||
|
||||
#include "in_kmsg.h"
|
||||
|
||||
@@ -123,12 +122,17 @@ static inline int process_line(const char *line,
|
||||
ctx->buffer_id++;
|
||||
|
||||
errno = 0;
|
||||
- val = strtol(p, &end, 10);
|
||||
- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN))
|
||||
+ val = strtoul(p, &end, 10);
|
||||
+ if ((errno == ERANGE && val == ULONG_MAX)
|
||||
|| (errno != 0 && val == 0)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
+ /* ensure something was consumed */
|
||||
+ if (end == p) {
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
/* Priority */
|
||||
priority = FLB_KLOG_PRI(val);
|
||||
|
||||
@@ -144,24 +148,35 @@ static inline int process_line(const char *line,
|
||||
}
|
||||
p++;
|
||||
|
||||
- val = strtoul(p, &end, 10);
|
||||
- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN))
|
||||
+ val = strtoull(p, &end, 10);
|
||||
+ if ((errno == ERANGE && val == ULLONG_MAX)
|
||||
|| (errno != 0 && val == 0)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
+ /* make sure strtoull consumed something */
|
||||
+ /* after the sequence number, the next char must be ',' */
|
||||
+ if (end == p || *end != ',') {
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
sequence = val;
|
||||
p = ++end;
|
||||
|
||||
/* Timestamp */
|
||||
- val = strtoul(p, &end, 10);
|
||||
- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN))
|
||||
+ val = strtoull(p, &end, 10);
|
||||
+ if ((errno == ERANGE && val == ULLONG_MAX)
|
||||
|| (errno != 0 && val == 0)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
+ /* ensure something was consumed */
|
||||
+ if (end == p) {
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
tv.tv_sec = val/1000000;
|
||||
- tv.tv_usec = val - (tv.tv_sec * 1000000);
|
||||
+ tv.tv_usec = val - ((uint64_t)tv.tv_sec * 1000000);
|
||||
|
||||
flb_time_set(&ts, ctx->boot_time.tv_sec + tv.tv_sec, tv.tv_usec * 1000);
|
||||
|
||||
Loading…
Add table
Reference in a new issue