d747d1a8fe
- tests: Fix formatting and snprintf warnings in tests. (bcl) - ui: Add checks for prompt being NULL (bcl) - strlist: Handle realloc error in wchar_to_str (bcl) - libparted: Fix potential NULL dereference in ped_disk_next_partition (bcl) - filesys: Check for null from close_fn (bcl)
51 lines
1.6 KiB
Diff
51 lines
1.6 KiB
Diff
From 09c95d2feab0c087339886134dfe2dc04094348a Mon Sep 17 00:00:00 2001
|
|
From: "Brian C. Lane" <bcl@redhat.com>
|
|
Date: Wed, 15 Feb 2023 11:15:28 -0800
|
|
Subject: [PATCH 21/24] ui: Add checks for prompt being NULL
|
|
|
|
Also removes a cast from const char* to char* when passing to readline
|
|
that doesn't appear to be necessary any longer.
|
|
|
|
Added asserts to make sure prompt isn't NULL after strdup and realloc
|
|
calls.
|
|
---
|
|
parted/ui.c | 7 +++++--
|
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/parted/ui.c b/parted/ui.c
|
|
index df14e55..9e5ced2 100644
|
|
--- a/parted/ui.c
|
|
+++ b/parted/ui.c
|
|
@@ -564,8 +564,7 @@ _readline (const char* prompt, const StrList* possibilities)
|
|
wipe_line ();
|
|
#ifdef HAVE_LIBREADLINE
|
|
if (!opt_script_mode) {
|
|
- /* XXX: why isn't prompt const? */
|
|
- line = readline ((char*) prompt);
|
|
+ line = readline (prompt);
|
|
if (line)
|
|
_add_history_unique (line);
|
|
} else
|
|
@@ -781,6 +780,8 @@ realloc_and_cat (char* str, const char* append)
|
|
int length = strlen (str) + strlen (append) + 1;
|
|
char* new_str = realloc (str, length);
|
|
|
|
+ PED_ASSERT(new_str != NULL);
|
|
+
|
|
strcat (new_str, append);
|
|
return new_str;
|
|
}
|
|
@@ -789,7 +790,9 @@ static char*
|
|
_construct_prompt (const char* head, const char* def,
|
|
const StrList* possibilities)
|
|
{
|
|
+ PED_ASSERT(head != NULL);
|
|
char* prompt = strdup (head);
|
|
+ PED_ASSERT(prompt != NULL);
|
|
|
|
if (def && possibilities)
|
|
PED_ASSERT (str_list_match_any (possibilities, def));
|
|
--
|
|
2.39.2
|
|
|