Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2401383lqt; Mon, 22 Apr 2024 09:39:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2Z02C5FpNMidvhnDvxffC/ax0Fs6GWO3SvWaBp2Owv23yubfr3LryNEkKzsNT2/N4Qa5TGjIDJgKUzr1wOLEwdpD1gyGSxVXSN16YzQ== X-Google-Smtp-Source: AGHT+IEp/KdjjFfZALLLkVPUh+i6oBdcIKiqlhwwCXvkzYJlZj7nHcx6FTeAWdU5UGoR4LZECoUZ X-Received: by 2002:a05:620a:9de:b0:78e:fd70:349f with SMTP id y30-20020a05620a09de00b0078efd70349fmr11114066qky.25.1713803940088; Mon, 22 Apr 2024 09:39:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713803940; cv=pass; d=google.com; s=arc-20160816; b=aWTviucu7hpljsQweu5mOjoV75wbEsb3m8FwhTTLtY66u37PfduXmkT0IvQJZArA2K v94TQCScXI9MlJ45De5AAFCy8xY4pa9xbox9UBx5k1XpNmVK5h9FfIQSP7+7f1IIwhB0 7/MnQ2wa7bJYmCgk0lPUc4DoF1VcfUBxZgKFgV8vrOlVqVHWj9ZD1rHcnwZ9FvEiJ7/z CpJlLBNjykAWY3bwjVo6N4ANt4iu6q36IUKquZPA+Efau4P2pXwtezi6G27m4WAhhnZU 9Vt/bVqWhnjcKk58NmKFbVqxRxEY2ZUZ5s4hSOIp6BdMaFXykQvOEW+Utx2BnDFJ2uem f4JQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=IaPzC1YdTbbmXVhdYLzIcA/Ug78Q+VkMF3OmhCOncvQ=; fh=84K/VpIR2yXXAo3It6qEiqI6m5pb/QkTe0pFmiz9mts=; b=So2CZTX8WWpFsK5TvfVer93IyWqOOUK9x6C9hfZ+wApaIm//pXR+6V3RO6ouJpQU1K GtDQJ7VYuGblxfgBeMOgYMQEzS+qE2/G4ezDRBVfIq3XkB5wp55FG/e7Ko9jVnWAQVDm uasEqqQVaB7OXVBGmb0jTtDlpBcBz8aUeT9uSLZ8FnDVq1HCjDXv0aNuhuB6IdTx0Xmh 74NjD4nY8I/Es8s8qK3a2knmHSSp2S8ZW0LLwAoyI9Mcbk5kILiAPRQs+MF+KoiTSm1T zavfMCL4Bmublo5R6zEcvOrzHBBiu76DXmBYpB78iMC34umKgEvURRMYrPWOqY3C5M1M q10A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="b5St/K84"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-153718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153718-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w14-20020a05620a0e8e00b0079068524cb3si4922026qkm.241.2024.04.22.09.38.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 09:39:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="b5St/K84"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-153718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153718-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CE77D1C20C76 for ; Mon, 22 Apr 2024 16:38:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB1D515382C; Mon, 22 Apr 2024 16:38:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="b5St/K84" Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 519D315381D for ; Mon, 22 Apr 2024 16:38:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713803882; cv=none; b=DdHCb1iEOOZhNQktUSbWO0dgCGZHOCb50GOMIwQcG0F689/VP16EO7+GGb5xP8zaNEVM5WfiZx8KYWp+G1WcXrVkoB5gR3YR7cG5WyrC91vG3dDwkeouA242HnVciYiGbaW1X6oBgfNCFSVybq2UGWn6JblDvZD+j1MHo3V16wA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713803882; c=relaxed/simple; bh=EKbL46mJOaKEQMG7PnN0H6MYhOBkih3jmYcm08ayvmY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fHC3YMtKs0mRMU5xX2Dni7Nbpo9GEFsTIuR9+C6FpxI+MCy2YW1TvQ0uLXDIJROHkHM5rXAV+YUD0p3my+NhNd4BGNVGYNXlM9HA/pLFCbw3QMExbw0qiNdRvbrkGtj3tLS/PFwZLmo7K0bOxpaaaeB5X9+avRPf7lGX90sooZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=b5St/K84; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4196c62bb4eso22226995e9.2 for ; Mon, 22 Apr 2024 09:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713803879; x=1714408679; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IaPzC1YdTbbmXVhdYLzIcA/Ug78Q+VkMF3OmhCOncvQ=; b=b5St/K847dFrkjjE7Q98iTlOeWDun6tiMDDvmC8kvGFHZaZV/HwYxCkaS/oUvB/dzc X42mnyFdTcrlW0U/84oJLz/OkLTODRwtHfIS4BoZtVZiLD3CS1dVUutcXM1ThyYFuy+F 51YGZ43MBHMJrj/QEB861FcypHMhp+9/PC1e7a4uM297t7jmcjknlTGWMGZP5MyN7u1i nxPPpp0ciFxkRE8sstpmHm5Ef+gwr8JXlcY6jMYZBi6r9LiYe4zzcvXF3zKL+qFkIuT2 Ggnrlc5nSHoCUFKmz3YmxsMlEIglcSQxJ3P1BQ5XJJ4w18CRLhZfTWYgJZyA1Vm58/fH bZ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713803879; x=1714408679; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IaPzC1YdTbbmXVhdYLzIcA/Ug78Q+VkMF3OmhCOncvQ=; b=EAAA1dWHgA0QicYpRCHch0STakpLQndwFr0qRJb0oQRPVRdhqoNzR62lYBRn2sPXGB 6e3EmPp/Y9Qn3a/mtbvAhtdPDbYIiCLfaJK58WSaODE2kzMFOQZDfJwcWSmX52UO7bsl NfyhvRXguxJDV7Xru2T1Hsgi+zs7oGE3aj5pKxGe6dakJk2etojJ3NYxAFVCt5ZfYiVj iL58oq5Z7i/YM6a+W2Sf0A5y9+XEhdV1bYzoUg4eeD5/IhrO9KAtOuZ5fZih5/Y2SQ5N ao3l7NL3u1sTFp3L2WX39oZPSDPtDx8qSyPDK77GXvb1i8Hn3QQIY+Nxt7ElreCRdFVU xFVA== X-Forwarded-Encrypted: i=1; AJvYcCVY3bGsS49yuEWHRK1JBi/jWWMGU4sLW+BxXxN0fWtXCtgzNURWrhCjuIskY8VaDwgjyB6DCYBXV/HCfxw7gzCeB4pQwIzGUmHsKQy7 X-Gm-Message-State: AOJu0YwsJjKSY7f6TJV93aB9Xa8XMI4YzDaWIwSqxU+uZ+OoELOlDAtr 4NwQeADH6rN0zsTZxPZK8rVxEaJgTbW0Z5k4oktEy2i1WORCN4bFSOVJjx1YRws= X-Received: by 2002:a05:600c:524e:b0:418:fc73:c0d3 with SMTP id fc14-20020a05600c524e00b00418fc73c0d3mr7093929wmb.24.1713803878838; Mon, 22 Apr 2024 09:37:58 -0700 (PDT) Received: from aspen.lan (aztw-34-b2-v4wan-166919-cust780.vm26.cable.virginm.net. [82.37.195.13]) by smtp.gmail.com with ESMTPSA id jp13-20020a05600c558d00b0041a9a6a2bebsm433343wmb.1.2024.04.22.09.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 09:37:57 -0700 (PDT) From: Daniel Thompson Date: Mon, 22 Apr 2024 17:35:58 +0100 Subject: [PATCH v2 5/7] kdb: Use format-specifiers rather than memset() for padding in kdb_read() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240422-kgdb_read_refactor-v2-5-ed51f7d145fe@linaro.org> References: <20240422-kgdb_read_refactor-v2-0-ed51f7d145fe@linaro.org> In-Reply-To: <20240422-kgdb_read_refactor-v2-0-ed51f7d145fe@linaro.org> To: Jason Wessel , Douglas Anderson Cc: kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, Daniel Thompson , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1348; i=daniel.thompson@linaro.org; h=from:subject:message-id; bh=EKbL46mJOaKEQMG7PnN0H6MYhOBkih3jmYcm08ayvmY=; b=owEBbQKS/ZANAwAKAXzjJV0594ihAcsmYgBmJpIzc+qxB+38dGrvf11xB/JwP24/5iyxfzXnR 7S9uLz9qIaJAjMEAAEKAB0WIQQvNUFTUPeVarpwrPB84yVdOfeIoQUCZiaSMwAKCRB84yVdOfeI oaVID/0VfTx+yaeruOa+2ykO35gx+u7NUo2WoPk0OF4mLglbzFwFCAFYEixVj0oZa2Qrvxi/7Zl Vg/X68oSztt6j/GiPZ28PTMgUH2F8CBg76ByY3EkKJRk+II13lqZXKldZV9vujuFr77rGBrnFfQ BwS3BEv4ne5B1QSbb572bByM6z8ir/cT0bC6b5231gZkxnh51sIEQxt+7ZvbOq33xsAaU4Z6xkK 83Nrt5ayJuolqgwtyuoFdPJB6u+ybUojj7MNE5Cd+x0zqRDtq4WYDPsbJzIG1ZVAjYDDULJnEom lCuxbBcTfbJtqtacC35zqD7XqcqLjtJBpvN/3Zj+I3ZbzsX6X3oSe6EdLm4uusxjKM0HXu+09Yz 1Gh0TwxPbaMvOrD3cijWo6CtGNXe5xLCnIgn3CvMHq6OpbcoZtQeM/L1Bd3UQnHh7O7mULCai+N fO7rrFexjVMwXnPAkeBA9+3pDbe5dITuKEwNSVBCqHhsfm47I0Q+w/5MzmUntEh+mbmFksyNxCy 34Aouq8LuayIGXynacVyDo1ORQ+YtyNyvwczP3zoTyFZo0pA7SszISNFTbPlzjU8k411CDYrTSW abYYUkMtPLM+TpNDxSrc8cb0U1bMVoGbo0PmPdOe8BPY1z6qasGJ6OSesjBergm3AiLEOV1FL+s BnSw0TsuHftAgzA== X-Developer-Key: i=daniel.thompson@linaro.org; a=openpgp; fpr=E38BE19861669213F6E2661AA8A4E3BC5B7B28BE Currently when the current line should be removed from the display kdb_read() uses memset() to fill a temporary buffer with spaces. The problem is not that this could be trivially implemented using a format string rather than open coding it. The real problem is that it is possible, on systems with a long kdb_prompt_str, to write pas the end of the tmpbuffer. Happily, as mentioned above, this can be trivially implemented using a format string. Make it so! Cc: stable@vger.kernel.org Signed-off-by: Daniel Thompson --- kernel/debug/kdb/kdb_io.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index f167894b11b8e..2cd17313fe652 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -299,11 +299,9 @@ static char *kdb_read(char *buffer, size_t bufsize) break; case 14: /* Down */ case 16: /* Up */ - memset(tmpbuffer, ' ', - strlen(kdb_prompt_str) + (lastchar-buffer)); - *(tmpbuffer+strlen(kdb_prompt_str) + - (lastchar-buffer)) = '\0'; - kdb_printf("\r%s\r", tmpbuffer); + kdb_printf("\r%*c\r", + (int)(strlen(kdb_prompt_str) + (lastchar - buffer)), + ' '); *lastchar = (char)key; *(lastchar+1) = '\0'; return lastchar; -- 2.43.0