clatd: introduce MAXDUMPLEN am: bea3f7f981
Original change: https://android-review.googlesource.com/c/platform/external/android-clat/+/2408792
Change-Id: Id6b0f04c643e32670a50fa43d53e9ef80de8e221
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/clatd.h b/clatd.h
index e810a3b..4be071c 100644
--- a/clatd.h
+++ b/clatd.h
@@ -43,6 +43,10 @@
// ie. if we ever read >= MAXMTU bytes we should discard.
#define MAXMTU (0xFFFF + 28 + 1)
#define PACKETLEN (sizeof(struct tun_pi) + MAXMTU)
+
+// logcat_hexdump() maximum binary data length
+#define MAXDUMPLEN PACKETLEN
+
#define CLATD_VERSION "1.5"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
diff --git a/dump.c b/dump.c
index 289f161..dff3d5e 100644
--- a/dump.c
+++ b/dump.c
@@ -226,11 +226,11 @@
/* generic hex dump */
void logcat_hexdump(const char *info, const uint8_t *data, size_t len) {
- char output[PACKETLEN * 3 + 2];
+ char output[MAXDUMPLEN * 3 + 2];
size_t i;
output[0] = '\0';
- for (i = 0; i < len && i < PACKETLEN; i++) {
+ for (i = 0; i < len && i < MAXDUMPLEN; i++) {
snprintf(output + i * 3, 4, " %02x", data[i]);
}
output[len * 3 + 3] = '\0';