From patchwork Mon Feb 5 13:02:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1895617 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=OatjcZCR; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TTf9x6svLz23g7 for ; Tue, 6 Feb 2024 21:09:40 +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=OatjcZCR; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TTf9v106tz2yyT for ; Tue, 6 Feb 2024 21:09:39 +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=OatjcZCR; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::52b; helo=mail-pg1-x52b.google.com; envelope-from=npiggin@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (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 4TT63y2lmyz3bWH for ; Tue, 6 Feb 2024 00:02:37 +1100 (AEDT) Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5ceb3fe708eso3356849a12.3 for ; Mon, 05 Feb 2024 05:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707138154; x=1707742954; 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=iXfbTONMd4usXd/QsauvQtQrIf/jGzFi91yVwXkg1VU=; b=OatjcZCRpxelNE9DF906uIgXMQAlBEF0/CASI0Ej2pYCX3Xj9KLgxhYAqK9Np92j+8 2/LgiU7WYpuW7rnMjBF7B/WcOMsAInZBRvhKUXYEDHijZQ5bBN2euu0vEBezpWA/V6Ul 8V3pWg+ty1bxYj30ez/x0QiErIeKLVCyI6zvrrfkMtEn+cbzCzNEkHYDr5CXDbQ085f7 ALij1U9AkN11sm/hZ+K5D6vJRVH56s+1rpH8bJit4ROO+znfAmRUXpsEHRsG04nGri2B LuzTsVspeXH9w/Pnhxb05bEHdYSL4WtEu7Jj//VzyTRF3RC6gU9L/XPn5WqBPMAJZ0U/ Pgpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707138154; x=1707742954; 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=iXfbTONMd4usXd/QsauvQtQrIf/jGzFi91yVwXkg1VU=; b=eNVHPs0qx9Y/b6fKgs1rBc0e788zTn1TvufMuAPJsNquuKyvGqV4AQGpF4i2ffLAvu 5+hAlQIKSDLkESwjaKjepyWV+wW+5Ytwl3VhorgI+Mrehvsv/kUKfe3ikxVLLiM1NPqs HMdBJLN52oF2DpFWPL8GxmWHZM8aO4pjdkV4952IiouX1QErvIT4XHFJuBSgHaarjsau Mu9a87A4hLKaMQgN2bhkjDUEnWeXz1GVe172LqzyGCmTRYkSN6Xg0iorTFtrhXVD8Her ubndOYVVbQ7Cg/qDcpzGK3Tjhhu/l9IZSDnFcttlvUatKmWWYzy+t+pU9eDPWrsyYFfg MMwQ== X-Gm-Message-State: AOJu0YzNqIBf2yiz0Ox2+MD7Te3YcjgZbPeqJOfnqOpOXERvmu1yFkCX d8UkHY4cbZTqeBgM7svLX0nuy0Y99rY1MbwP/JNJm+Zja1UMK/o9EexFVcv2 X-Google-Smtp-Source: AGHT+IFQxluAIqG7QUBXELgT38YrSTNcrJVAxZtwN/95gfWfhjr5quJwpwdqKG6u27rwGFft0/XFug== X-Received: by 2002:a05:6a00:2355:b0:6e0:4e7e:ef57 with SMTP id j21-20020a056a00235500b006e04e7eef57mr1013952pfj.32.1707138154306; Mon, 05 Feb 2024 05:02:34 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUwX2F5KBpaiFH6p2urJ80WbFiyZl7kMTGuGVJ1UtL4POWH1cIhv8oDHE94RoxsYx7MRHEADsEKkbHRRBH8+7EVdfu+IUZ1VobWwC8p/V6pQniBT3pT/Sy0woXD9w== 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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 05:02:34 -0800 (PST) From: Nicholas Piggin To: petitboot@lists.ozlabs.org, Jeremy Kerr Subject: [PATCH 1/2] ui: Fix compile with curses opaque menu headers Date: Mon, 5 Feb 2024 23:02:08 +1000 Message-ID: <20240205130209.222045-2-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" Recent Debian ncurses is built with NCURSES_OPAQUE_MENU, which means the menu item type can't be poked directly. Fix with accessors. One wrinkle is the item name can't be modified, new_item has to be used. Signed-off-by: Nicholas Piggin --- ui/ncurses/nc-menu.c | 12 ++++++++---- ui/ncurses/nc-menu.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c index a90a02e..a1524b5 100644 --- a/ui/ncurses/nc-menu.c +++ b/ui/ncurses/nc-menu.c @@ -141,9 +141,13 @@ int pmenu_item_update(struct pmenu_item *item, const char *name) if (!label) return -1; - i = item->nci; - i->name.str = label; - i->name.length = strncols(label); + i = new_item(label, NULL); + if (!i) { + talloc_free((char *)label); + return -1; + } + free_item(item->nci); + item->nci = i; return 0; } @@ -358,7 +362,7 @@ static int pmenu_item_get_index(const struct pmenu_item *item) return i; pb_log_fn("not found: %p %s\n", item, - (item ? item->nci->name.str : "(null)")); + (item ? item_name(item->nci) : "(null)")); return -1; } diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h index eb568c8..550c7e1 100644 --- a/ui/ncurses/nc-menu.h +++ b/ui/ncurses/nc-menu.h @@ -126,7 +126,7 @@ static inline struct pmenu *pmenu_from_scr(struct nc_scr *scr) static inline void pmenu_dump_item(const ITEM *item) { - pb_debug("%p %s\n", item, (item ? item->name.str : "(null)")); + pb_debug("%p %s\n", item, (item ? item_name(item) : "(null)")); } static inline void pmenu_dump_items(ITEM *const *items, unsigned int count) @@ -135,7 +135,7 @@ static inline void pmenu_dump_items(ITEM *const *items, unsigned int count) for (i = 0; i < count; i++) pb_debug("%u: %p %s\n", i, items[i], - (items[i] ? items[i]->name.str : "(null)")); + (items[i] ? item_name(items[i]) : "(null)")); } #endif 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;