applied with fix: https://github.com/crash-utility/crash/commit/5a564c2adfda54467d6db01c31800070c270344c
On Fri, Oct 31, 2025 at 12:41 PM Tao Liu <[email protected]> wrote: > > On Thu, Oct 30, 2025 at 8:58 PM lijiang <[email protected]> wrote: > > > > Hi, Tao > > Thank you for the update. > > On Tue, Oct 28, 2025 at 6:59 AM <[email protected]> > > wrote: > >> > >> Date: Tue, 28 Oct 2025 11:40:03 +1300 > >> From: Tao Liu <[email protected]> > >> Subject: [Crash-utility] [PATCH v3 1/2] extensions: Search all > >> possible paths > >> To: [email protected] > >> Cc: [email protected] > >> Message-ID: <[email protected]> > >> Content-Type: text/plain; charset="US-ASCII"; x-default=true > >> > >> Search all possible paths for extensions. Previously if one path, e.g. > >> "/usr/lib64/crash/extensions" exists, but no extensions found within, > >> crash will not search any later paths, e.g. "./extensions". This patch > >> will let crash continue to search any later paths. > >> > >> Signed-off-by: Tao Liu <[email protected]> > >> --- > >> extensions.c | 59 ++++++++++++++++++++++++++++------------------------ > >> 1 file changed, 32 insertions(+), 27 deletions(-) > >> > >> diff --git a/extensions.c b/extensions.c > >> index d23b1e3..099af3b 100644 > >> --- a/extensions.c > >> +++ b/extensions.c > >> @@ -19,7 +19,7 @@ > >> #include <dlfcn.h> > >> > >> static int in_extensions_library(char *, char *); > >> -static char *get_extensions_directory(char *); > >> +static char *get_extensions_directory(char *, bool *); > >> static void show_all_extensions(void); > >> static void show_extensions(char *); > >> > >> @@ -395,32 +395,29 @@ in_extensions_library(char *lib, char *buf) > >> * Look for an extensions directory using the proper order. > >> */ > >> static char * > >> -get_extensions_directory(char *dirbuf) > >> +get_extensions_directory(char *dirbuf, bool *end) > >> { > >> - char *env; > >> + static int index = 0; > > > > > >> > >> + char *dirs[] = { > >> + getenv("CRASH_EXTENSIONS"), > >> + BITS64() ? "/usr/lib64/crash/extensions" : NULL, > >> + "/usr/lib/crash/extensions", > >> + "./extensions", > >> + }; > >> + char *dir; > >> > >> - if ((env = getenv("CRASH_EXTENSIONS"))) { > >> - if (is_directory(env)) { > >> - strcpy(dirbuf, env); > >> - return dirbuf; > >> - } > >> + if (index >= sizeof(dirs) / sizeof(char *)) { > >> + *end = true; > >> + return NULL; > >> } > >> - > >> - if (BITS64()) { > >> - sprintf(dirbuf, "/usr/lib64/crash/extensions"); > >> - if (is_directory(dirbuf)) > >> - return dirbuf; > >> + *end = false; > >> + dir = dirs[index++]; > >> + if (is_directory(dir)) { > >> + snprintf(dirbuf, BUFSIZE - 1, "%s", dir); > > > > > > The snprintf() won't write more than BUFSIZE - 1 characters and will always > > null-terminate the buffer(including the terminating null byte ('\0')), > > so using the BUFSIZE should be safe and correct. > > Right, thanks for pointing it out. I will fix it when merge. > > Thanks, > Tao Liu > > > > > Other changes are fine to me. Otherwise: Ack. > > > > Thanks > > Lianbo > > > > > >> + return dir; > >> + } else { > >> + return NULL; > >> } > >> - > >> - sprintf(dirbuf, "/usr/lib/crash/extensions"); > >> - if (is_directory(dirbuf)) > >> - return dirbuf; > >> - > >> - sprintf(dirbuf, "./extensions"); > >> - if (is_directory(dirbuf)) > >> - return dirbuf; > >> - > >> - return NULL; > >> } > >> > >> > >> @@ -432,14 +429,20 @@ preload_extensions(void) > >> char dirbuf[BUFSIZE]; > >> char filename[BUFSIZE*2]; > >> int found; > >> + bool end; > >> > >> - if (!get_extensions_directory(dirbuf)) > >> - return; > >> +next_dir: > >> + if (!get_extensions_directory(dirbuf, &end)) { > >> + if (end) > >> + return; > >> + else > >> + goto next_dir; > >> + } > >> > >> dirp = opendir(dirbuf); > >> if (!dirp) { > >> error(INFO, "%s: %s\n", dirbuf, strerror(errno)); > >> - return; > >> + goto next_dir; > >> } > >> > >> pc->curcmd = pc->program_name; > >> @@ -461,10 +464,12 @@ preload_extensions(void) > >> > >> if (found) > >> fprintf(fp, "\n"); > >> - else > >> + else { > >> error(NOTE, > >> "%s: no extension modules found in directory\n\n", > >> dirbuf); > >> + goto next_dir; > >> + } > >> } > >> > >> /* > >> -- > >> 2.47.0 -- Crash-utility mailing list -- [email protected] To unsubscribe send an email to [email protected] https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/ Contribution Guidelines: https://github.com/crash-utility/crash/wiki
