lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 24 Oct 2022 13:56:29 +0800
From:   Li zeming <zeming@...china.com>
To:     masahiroy@...nel.org
Cc:     linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
        Li zeming <zeming@...china.com>
Subject: [PATCH] lxdialog: menubox: Add malloc allocation judgment

Add menu_item Only when the pointer judges that the pointer is valid
can function code be executed.

Signed-off-by: Li zeming <zeming@...china.com>
---
 scripts/kconfig/lxdialog/menubox.c | 53 +++++++++++++++---------------
 1 file changed, 27 insertions(+), 26 deletions(-)

diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 58c2f8afe59b..2ae263ad477e 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -55,34 +55,35 @@ static void do_print_item(WINDOW * win, const char *item, int line_y,
 {
 	int j;
 	char *menu_item = malloc(menu_width + 1);
+	if (menu_item) {
+		strncpy(menu_item, item, menu_width - item_x);
+		menu_item[menu_width - item_x] = '\0';
+		j = first_alpha(menu_item, "YyNnMmHh");
 
-	strncpy(menu_item, item, menu_width - item_x);
-	menu_item[menu_width - item_x] = '\0';
-	j = first_alpha(menu_item, "YyNnMmHh");
-
-	/* Clear 'residue' of last item */
-	wattrset(win, dlg.menubox.atr);
-	wmove(win, line_y, 0);
-#if OLD_NCURSES
-	{
-		int i;
-		for (i = 0; i < menu_width; i++)
-			waddch(win, ' ');
-	}
-#else
-	wclrtoeol(win);
-#endif
-	wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
-	mvwaddstr(win, line_y, item_x, menu_item);
-	if (hotkey) {
-		wattrset(win, selected ? dlg.tag_key_selected.atr
-			 : dlg.tag_key.atr);
-		mvwaddch(win, line_y, item_x + j, menu_item[j]);
-	}
-	if (selected) {
-		wmove(win, line_y, item_x + 1);
+		/* Clear 'residue' of last item */
+		wattrset(win, dlg.menubox.atr);
+		wmove(win, line_y, 0);
+	#if OLD_NCURSES
+		{
+			int i;
+			for (i = 0; i < menu_width; i++)
+				waddch(win, ' ');
+		}
+	#else
+		wclrtoeol(win);
+	#endif
+		wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
+		mvwaddstr(win, line_y, item_x, menu_item);
+		if (hotkey) {
+			wattrset(win, selected ? dlg.tag_key_selected.atr
+				 : dlg.tag_key.atr);
+			mvwaddch(win, line_y, item_x + j, menu_item[j]);
+		}
+		if (selected) {
+			wmove(win, line_y, item_x + 1);
+		}
+		free(menu_item);
 	}
-	free(menu_item);
 	wrefresh(win);
 }
 
-- 
2.18.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ