From 20de0ab96af89bc15ea867be14560596cf99b67f Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Fri, 9 Feb 2024 11:42:32 -0500 Subject: [PATCH] pw-dot: truncate escaped string values to 128 This avoids objects in the graph being too big if one of their properties has a long value (Eg 'pipewire.sec.label' in the client objects). --- src/tools/pw-dot.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tools/pw-dot.c b/src/tools/pw-dot.c index a8b00abc7..0dfcdc3d4 100644 --- a/src/tools/pw-dot.c +++ b/src/tools/pw-dot.c @@ -22,6 +22,7 @@ #define GLOBAL_ID_NONE UINT32_MAX #define DEFAULT_DOT_PATH "pw.dot" #define DEFAULT_DOT_DATA_SIZE 2048 +#define MAX_ESCAPED_LEN 128 struct global; @@ -140,6 +141,12 @@ static int escape_quotes(char *str, int size, const char *val) break; } val++; + + /* Truncate with "..." if string has more than escaped len characters. */ + if (len >= MAX_ESCAPED_LEN) { + __PUT('.'); __PUT('.'); __PUT('.'); + break; + } } __PUT('\0'); #undef __PUT