@@ -180,6 +180,8 @@ void flb_log_event_decoder_destroy(struct flb_log_event_decoder *context)
180180int flb_log_event_decoder_decode_timestamp (msgpack_object * input ,
181181 struct flb_time * output )
182182{
183+ uint32_t packed_sec ;
184+
183185 flb_time_zero (output );
184186
185187 if (input -> type == MSGPACK_OBJECT_POSITIVE_INTEGER ) {
@@ -194,13 +196,23 @@ int flb_log_event_decoder_decode_timestamp(msgpack_object *input,
194196 return FLB_EVENT_DECODER_ERROR_WRONG_TIMESTAMP_TYPE ;
195197 }
196198
197- output -> tm . tv_sec =
198- ( int32_t ) FLB_UINT32_TO_HOST_BYTE_ORDER (
199+ /* convert uint_32t style seconds to time_t style seconds */
200+ packed_sec = FLB_UINT32_TO_HOST_BYTE_ORDER (
199201 FLB_ALIGNED_DWORD_READ (
200202 (unsigned char * ) & input -> via .ext .ptr [0 ]));
201203
204+ if (packed_sec == (uint32_t ) FLB_LOG_EVENT_GROUP_START ) {
205+ output -> tm .tv_sec = FLB_LOG_EVENT_GROUP_START ;
206+ }
207+ else if (packed_sec == (uint32_t ) FLB_LOG_EVENT_GROUP_END ) {
208+ output -> tm .tv_sec = FLB_LOG_EVENT_GROUP_END ;
209+ }
210+ else {
211+ output -> tm .tv_sec = (time_t ) packed_sec ;
212+ }
213+
202214 output -> tm .tv_nsec =
203- (int32_t ) FLB_UINT32_TO_HOST_BYTE_ORDER (
215+ (time_t ) FLB_UINT32_TO_HOST_BYTE_ORDER (
204216 FLB_ALIGNED_DWORD_READ (
205217 (unsigned char * ) & input -> via .ext .ptr [4 ]));
206218 }
@@ -313,7 +325,7 @@ int flb_log_event_decoder_next(struct flb_log_event_decoder *context,
313325 int result ;
314326 int record_type ;
315327 size_t previous_offset ;
316- int32_t invalid_timestamp ;
328+ int64_t invalid_timestamp ;
317329
318330 if (context == NULL ) {
319331 return FLB_EVENT_DECODER_ERROR_INVALID_CONTEXT ;
@@ -368,8 +380,8 @@ int flb_log_event_decoder_next(struct flb_log_event_decoder *context,
368380 * to avoid losing valid group metadata if corruption occurs mid-group.
369381 * Skip the record and continue processing.
370382 */
371- invalid_timestamp = (int32_t ) event -> timestamp .tm .tv_sec ;
372- flb_debug ("[decoder] Invalid group marker timestamp (%d ), skipping record. "
383+ invalid_timestamp = (int64_t ) event -> timestamp .tm .tv_sec ;
384+ flb_debug ("[decoder] Invalid group marker timestamp (%ld ), skipping record. "
373385 "Group state preserved." , invalid_timestamp );
374386
375387 /* Increment recursion depth before recursive call */
@@ -457,22 +469,22 @@ int flb_log_event_decoder_next(struct flb_log_event_decoder *context,
457469
458470int flb_log_event_decoder_get_record_type (struct flb_log_event * event , int32_t * type )
459471{
460- int32_t s ;
472+ time_t s ;
461473
462- s = ( int32_t ) event -> timestamp .tm .tv_sec ;
474+ s = event -> timestamp .tm .tv_sec ;
463475
464- if (s >= 0 ) {
465- * type = FLB_LOG_EVENT_NORMAL ;
466- return 0 ;
467- }
468- else if (s == FLB_LOG_EVENT_GROUP_START ) {
476+ if (s == FLB_LOG_EVENT_GROUP_START ) {
469477 * type = FLB_LOG_EVENT_GROUP_START ;
470478 return 0 ;
471479 }
472480 else if (s == FLB_LOG_EVENT_GROUP_END ) {
473481 * type = FLB_LOG_EVENT_GROUP_END ;
474482 return 0 ;
475483 }
484+ else if (s >= 0 ) {
485+ * type = FLB_LOG_EVENT_NORMAL ;
486+ return 0 ;
487+ }
476488
477489 return -1 ;
478490}
0 commit comments