From 80833e2886e89865a733710a29943af1c9e6c56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Mon, 13 Jan 2020 15:28:22 +0100 Subject: [PATCH] Master: Fix issue where describe_string() could lengthen the output. Fixes edge-case where the string to be formatted (m) is shorter than the maxlen, but the formatted string (t) is longer. This caused the truncation code to instead lengthen the string... Fixes [PIKE-224]. --- .gitattributes | 1 - lib/master.pike.in | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 1236c4027c..2a7ecb273b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -60,7 +60,6 @@ testfont binary /lib/7.4/modules/SSL.pmod/constants.pike foreign_ident /lib/7.4/modules/__default.pmod foreign_ident /lib/include/profiling.h foreign_ident -/lib/master.pike.in foreign_ident /lib/modules/ADT.pmod/History.pike foreign_ident /lib/modules/ADT.pmod/Queue.pike foreign_ident /lib/modules/ADT.pmod/Relation.pmod/Binary.pike foreign_ident diff --git a/lib/master.pike.in b/lib/master.pike.in index cc5f7cd2b4..3c98a78794 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -6,7 +6,7 @@ // Pike is distributed under GPL, LGPL and MPL. See the file COPYING // for more information. // -// $Id: master.pike.in,v 1.331 2004/01/12 23:37:07 nilsson Exp $ +// $Id$ #pike __REAL_VERSION__ @@ -2818,6 +2818,9 @@ class Describer string t = sprintf("%O", m); if (sizeof(t) < (maxlen + 2)) return t; + // NB: The code further below requires maxlen <= sizeof(m). + // We adjust maxlen so that this holds. Cf [PIKE-224]. + maxlen = sizeof(m) - (sizeof(t) - maxlen); t = 0; } clipped++; -- GitLab