From: Lennart Poettering Date: Thu, 3 Apr 2025 13:00:54 +0000 (+0200) Subject: logs-show: use memory_startswith() rather than startswith() X-Git-Tag: v258-rc1~633^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6427d0fbed998e5e306e95dfe227c8598a3e4ad1;p=thirdparty%2Fsystemd.git logs-show: use memory_startswith() rather than startswith() Let's be strict here: this data is conceptually not NUL terminated, hence use memory_startswith() rather than startswith() (which implies NUL termination). All other similar cases in logs-show.c got this right. Fix the remaining three, too. --- diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 9f9e74f99a4..270fe2bc345 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -866,10 +866,10 @@ static int output_verbose( p = c + 1; if (flags & OUTPUT_COLOR) { - if (startswith(data, "MESSAGE=")) { + if (memory_startswith(data, length, "MESSAGE=")) { on = ansi_highlight(); off = ansi_normal(); - } else if (startswith(data, "CONFIG_FILE=")) { + } else if (memory_startswith(data, length, "CONFIG_FILE=")) { _cleanup_free_ char *u = NULL; u = memdup_suffix0(p, valuelen); @@ -881,7 +881,7 @@ static int output_verbose( valuelen = strlen(urlified); } - } else if (startswith(data, "_")) { + } else if (memory_startswith(data, length, "_")) { /* Highlight trusted data as such */ on = ansi_green(); off = ansi_normal();