[ulogd2 PATCH v2 24/27] output: JSON: fix printf truncation warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mod gmt offset by 86400 to give the compiler a hint.

Make date-time buffer big enough to fit all integer values.

Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 output/ulogd_output_JSON.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/output/ulogd_output_JSON.c b/output/ulogd_output_JSON.c
index 621333261733..6c61eb144135 100644
--- a/output/ulogd_output_JSON.c
+++ b/output/ulogd_output_JSON.c
@@ -269,7 +269,7 @@ static int json_interp_file(struct ulogd_pluginstance *upi, char *buf)
 	return ULOGD_IRET_OK;
 }
 
-#define MAX_LOCAL_TIME_STRING 38
+#define MAX_LOCAL_TIME_STRING 80
 
 static int json_interp(struct ulogd_pluginstance *upi)
 {
@@ -305,8 +305,8 @@ static int json_interp(struct ulogd_pluginstance *upi)
 			snprintf(opi->cached_tz, sizeof(opi->cached_tz),
 				 "%c%02ld%02ld",
 				 t->tm_gmtoff > 0 ? '+' : '-',
-				 labs(t->tm_gmtoff) / 60 / 60,
-				 labs(t->tm_gmtoff) / 60 % 60);
+				 labs(t->tm_gmtoff) % 86400 / 60 / 60,
+				 labs(t->tm_gmtoff) % 86400 / 60 % 60);
 		}
 
 		if (pp_is_valid(inp, opi->usec_idx)) {
-- 
2.33.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux