diff mbox series

[ulogd2,2/3] output: add missing support for int64_t values

Message ID 20221127002300.191936-3-jeremy@azazel.net
State Accepted
Delegated to: Pablo Neira
Headers show
Series IP Address Formatting Fixes | expand

Commit Message

Jeremy Sowden Nov. 27, 2022, 12:22 a.m. UTC
Some of the output plug-ins don't handle 64-bit signed values.

Fix formatting of OPRINT switch.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
 output/ulogd_output_GPRINT.c |  4 ++-
 output/ulogd_output_JSON.c   |  3 ++
 output/ulogd_output_OPRINT.c | 55 +++++++++++++++++++-----------------
 3 files changed, 35 insertions(+), 27 deletions(-)

Comments

Pablo Neira Ayuso Dec. 8, 2022, 9:45 p.m. UTC | #1
On Sun, Nov 27, 2022 at 12:22:59AM +0000, Jeremy Sowden wrote:
> Some of the output plug-ins don't handle 64-bit signed values.
> 
> Fix formatting of OPRINT switch.

Also applied, thanks
diff mbox series

Patch

diff --git a/output/ulogd_output_GPRINT.c b/output/ulogd_output_GPRINT.c
index aedd08e980f7..eeeec6ac3eb0 100644
--- a/output/ulogd_output_GPRINT.c
+++ b/output/ulogd_output_GPRINT.c
@@ -127,13 +127,15 @@  static int gprint_interp(struct ulogd_pluginstance *upi)
 		case ULOGD_RET_INT8:
 		case ULOGD_RET_INT16:
 		case ULOGD_RET_INT32:
+		case ULOGD_RET_INT64:
 			ret = snprintf(buf+size, rem, "%s=", key->name);
 			if (ret < 0)
 				break;
 			rem -= ret;
 			size += ret;
 
-			ret = snprintf(buf+size, rem, "%d,", key->u.value.i32);
+			ret = snprintf(buf+size, rem, "%" PRId64 ",",
+				       key->u.value.i64);
 			if (ret < 0)
 				break;
 			rem -= ret;
diff --git a/output/ulogd_output_JSON.c b/output/ulogd_output_JSON.c
index bbc3dba5d41a..32d020ac657a 100644
--- a/output/ulogd_output_JSON.c
+++ b/output/ulogd_output_JSON.c
@@ -366,6 +366,9 @@  static int json_interp(struct ulogd_pluginstance *upi)
 		case ULOGD_RET_INT32:
 			json_object_set_new(msg, field_name, json_integer(key->u.value.i32));
 			break;
+		case ULOGD_RET_INT64:
+			json_object_set_new(msg, field_name, json_integer(key->u.value.i64));
+			break;
 		case ULOGD_RET_UINT8:
 			if ((upi->config_kset->ces[JSON_CONF_BOOLEAN_LABEL].u.value != 0)
 					&& (!strcmp(key->name, "raw.label"))) {
diff --git a/output/ulogd_output_OPRINT.c b/output/ulogd_output_OPRINT.c
index 6fde445ed1e4..8617203237c3 100644
--- a/output/ulogd_output_OPRINT.c
+++ b/output/ulogd_output_OPRINT.c
@@ -65,32 +65,35 @@  static int oprint_interp(struct ulogd_pluginstance *upi)
 
 		fprintf(opi->of,"%s=", ret->name);
 		switch (ret->type) {
-			case ULOGD_RET_STRING:
-				fprintf(opi->of, "%s\n",
-					(char *) ret->u.value.ptr);
-				break;
-			case ULOGD_RET_BOOL:
-			case ULOGD_RET_INT8:
-			case ULOGD_RET_INT16:
-			case ULOGD_RET_INT32:
-				fprintf(opi->of, "%d\n", ret->u.value.i32);
-				break;
-			case ULOGD_RET_UINT8:
-			case ULOGD_RET_UINT16:
-			case ULOGD_RET_UINT32:
-				fprintf(opi->of, "%u\n", ret->u.value.ui32);
-				break;
-			case ULOGD_RET_UINT64:
-				fprintf(opi->of, "%" PRIu64 "\n", ret->u.value.ui64);
-				break;
-			case ULOGD_RET_IPADDR:
-				fprintf(opi->of, "%u.%u.%u.%u\n", 
-					HIPQUAD(ret->u.value.ui32));
-				break;
-			case ULOGD_RET_NONE:
-				fprintf(opi->of, "<none>\n");
-				break;
-			default: fprintf(opi->of, "default\n");
+		case ULOGD_RET_STRING:
+			fprintf(opi->of, "%s\n",
+				(char *) ret->u.value.ptr);
+			break;
+		case ULOGD_RET_BOOL:
+		case ULOGD_RET_INT8:
+		case ULOGD_RET_INT16:
+		case ULOGD_RET_INT32:
+			fprintf(opi->of, "%d\n", ret->u.value.i32);
+			break;
+		case ULOGD_RET_INT64:
+			fprintf(opi->of, "%" PRId64 "\n", ret->u.value.i64);
+			break;
+		case ULOGD_RET_UINT8:
+		case ULOGD_RET_UINT16:
+		case ULOGD_RET_UINT32:
+			fprintf(opi->of, "%u\n", ret->u.value.ui32);
+			break;
+		case ULOGD_RET_UINT64:
+			fprintf(opi->of, "%" PRIu64 "\n", ret->u.value.ui64);
+			break;
+		case ULOGD_RET_IPADDR:
+			fprintf(opi->of, "%u.%u.%u.%u\n",
+				HIPQUAD(ret->u.value.ui32));
+			break;
+		case ULOGD_RET_NONE:
+			fprintf(opi->of, "<none>\n");
+			break;
+		default: fprintf(opi->of, "default\n");
 		}
 	}
 	if (upi->config_kset->ces[1].u.value != 0)