mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-01-28 01:47:19 +01:00
70 lines
1.8 KiB
Diff
70 lines
1.8 KiB
Diff
diff --git a/plugins/in_kmsg/in_kmsg.c b/plugins/in_kmsg/in_kmsg.c
|
|
index fe372a9a2..6acb34893 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"
|
|
|
|
@@ -114,7 +113,7 @@ static inline int process_line(const char *line,
|
|
struct timeval tv; /* time value */
|
|
int line_len;
|
|
uint64_t val;
|
|
- long pri_val;
|
|
+ unsigned long pri_val;
|
|
const char *p = line;
|
|
char *end = NULL;
|
|
struct flb_time ts;
|
|
@@ -124,12 +123,17 @@ static inline int process_line(const char *line,
|
|
ctx->buffer_id++;
|
|
|
|
errno = 0;
|
|
- pri_val = strtol(p, &end, 10);
|
|
- if ((errno == ERANGE && (pri_val == INT_MAX || pri_val == INT_MIN))
|
|
+ pri_val = strtoul(p, &end, 10);
|
|
+ if ((errno == ERANGE && pri_val == ULONG_MAX)
|
|
|| (errno != 0 && pri_val == 0)) {
|
|
goto fail;
|
|
}
|
|
|
|
+ /* ensure something was consumed */
|
|
+ if (end == p) {
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
/* Priority */
|
|
priority = FLB_KLOG_PRI(pri_val);
|
|
|
|
@@ -152,6 +156,12 @@ static inline int process_line(const char *line,
|
|
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;
|
|
|
|
@@ -162,8 +172,14 @@ static inline int process_line(const char *line,
|
|
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);
|
|
|