From patchwork Mon Feb 5 13:02:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1895619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=nBffTLw4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TTfB52dQhz23g7 for ; Tue, 6 Feb 2024 21:09:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=nBffTLw4; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TTfB51ZJcz3bWH for ; Tue, 6 Feb 2024 21:09:49 +1100 (AEDT) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=nBffTLw4; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::52a; helo=mail-pg1-x52a.google.com; envelope-from=npiggin@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TT6401Z72z3bWH for ; Tue, 6 Feb 2024 00:02:39 +1100 (AEDT) Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5d8df34835aso2076368a12.0 for ; Mon, 05 Feb 2024 05:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707138157; x=1707742957; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8a7G/ZVSCDuMQDZQNzWerZ/I/g5t45iJxCyHuR14p5o=; b=nBffTLw47H6fYwKxq7Dozl5deqbg+wGHn/xMVsOh2rqV3mERJMUvRXtbx9rXYBXzOq MGlitW6054R+6eNdCsaFCi/nHcPBO0d7E67mujrk+AzXBQpxe2NIcj0rT9XJ3zLIY/j/ u0eHjssiTSUfkGHXx9TQ9d6Jlgd3NeGZ+DCz6ng6NVk0UV3DG/Dz/77JxZRXNuZ9GPE0 zbXpid0QWuAwFQabTaK5XYuLtIQprsNSadsYzsE7Y4uzNt4i5yhmmdANQnLv4T37Wywd LSnzqR+NvP+i6BuZQpb1jrGpC5h/ePZ7g3H71k3uXx9kNC7j3NuMfzqAz/STp32bu08v oaPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707138157; x=1707742957; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8a7G/ZVSCDuMQDZQNzWerZ/I/g5t45iJxCyHuR14p5o=; b=q7kyAkqvfDe2qsp8hVJVTrq7z1FAQqEVjLUKeo39H1OplhoHAhvfwgLDQsuyI9oMlj JXKqSc1OzYVe21w8tBN7IKcrdycKCsXyhXUcfJj+yhlqHkqtx2ugq6WYVMfZ9QkN+Exv 2zRmluxsrHLCvgMfPt5NB3Gfcg8xyZO5HVB2avMOJbGhTwLM1RAa1Npx0Fon72N6JMqp XqSXrVZgaDHNWH3gFSVYOZ4VvtumGkGjI+Xl8RbiccLpCA6u6sa4ONjrFiDfhniwdBoc 9sg5BEd2u+4F/Q6sjd64Dmu/iAbTYBfWhBrK1ScIph6w1/kxDxrDpQmY3rhghMSlVtJI LvnQ== X-Gm-Message-State: AOJu0YwyQ71906YdO/uum9srwesJ32VJsuoPrDUT3a/FRe6kJDCtA5pg ryzqA4gagqALGQP8vgjIv5UdQ43OY7D8dKhMWBZ+UugVjAbjLZOqqIWyri1I X-Google-Smtp-Source: AGHT+IFrCnBpSLJ2qAzpgxYV8OYF8UiCRO92iKKY7e/YZDdh2V7fpMz+aIKdOKirFNTIxOF+zf+X/A== X-Received: by 2002:a05:6a21:a5a4:b0:19e:2c0a:e6e4 with SMTP id gd36-20020a056a21a5a400b0019e2c0ae6e4mr9584242pzc.15.1707138157098; Mon, 05 Feb 2024 05:02:37 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCW8QjsQX/udP0N7vQTCRGVM2T02tWIuhAJpYQ5SbZbMY1zHWOw+daiMQX6EUOc6EdHYxW6Lqo06jQ3h3Ms43W0IHu+KCMqwASiS74fOWEWyXkspXu/sr+Dxs9Fb1g== Received: from wheely.local0.net (193-116-252-169.tpgi.com.au. [193.116.252.169]) by smtp.gmail.com with ESMTPSA id e13-20020a056a001a8d00b006db9604bf8csm6574526pfv.131.2024.02.05.05.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 05:02:36 -0800 (PST) From: Nicholas Piggin To: petitboot@lists.ozlabs.org, Jeremy Kerr Subject: [PATCH 2/2] ui: Fix curses menu item label leak Date: Mon, 5 Feb 2024 23:02:09 +1000 Message-ID: <20240205130209.222045-3-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240205130209.222045-1-npiggin@gmail.com> References: <20240205130209.222045-1-npiggin@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 06 Feb 2024 21:09:35 +1100 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" When a menu item name is updated, the old label is not freed. Signed-off-by: Nicholas Piggin --- ui/ncurses/nc-menu.c | 4 ++++ ui/ncurses/nc-menu.h | 1 + 2 files changed, 5 insertions(+) diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c index a1524b5..70f2210 100644 --- a/ui/ncurses/nc-menu.c +++ b/ui/ncurses/nc-menu.c @@ -82,6 +82,7 @@ static void pmenu_resize(struct nc_scr *scr) static int pmenu_item_destructor(void *arg) { struct pmenu_item *item = arg; + talloc_free((char *)item->label); free_item(item->nci); return 0; } @@ -146,7 +147,9 @@ int pmenu_item_update(struct pmenu_item *item, const char *name) talloc_free((char *)label); return -1; } + talloc_free((char *)item->label); free_item(item->nci); + item->label = label; item->nci = i; return 0; @@ -168,6 +171,7 @@ struct pmenu_item *pmenu_item_create(struct pmenu *menu, const char *name) item->i_sig = pb_item_sig; item->pmenu = menu; + item->label = label; item->nci = new_item(label, NULL); if (!item->nci) { diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h index 550c7e1..7ba45bf 100644 --- a/ui/ncurses/nc-menu.h +++ b/ui/ncurses/nc-menu.h @@ -46,6 +46,7 @@ struct pmenu; struct pmenu_item { enum pb_nc_sig i_sig; + const char *label; ITEM *nci; struct pmenu *pmenu; void *data;