diff --git a/src/file.c b/src/file.c index 94ff234c..c1153732 100644 --- a/src/file.c +++ b/src/file.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2007-2015 Kim Woelders + * Copyright (C) 2007-2020 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -321,3 +321,13 @@ path_canexec(const char *file) Efree(s); return 1; } + +int +path_canexec0(const char *cmd) +{ + char exe[4096]; + + sscanf(cmd, "%4000s", exe); + + return path_canexec(exe); +} diff --git a/src/file.h b/src/file.h index 6c1a0e8b..0ac70439 100644 --- a/src/file.h +++ b/src/file.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2007 Kim Woelders + * Copyright (C) 2007-2020 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -60,5 +60,6 @@ const char *fullfileof(const char *s); char *path_test(const char *file, unsigned int test); int path_canexec(const char *file); +int path_canexec0(const char *cmd); #endif /* _FILE_H_ */ diff --git a/src/menus-misc.c b/src/menus-misc.c index b0749094..e6c93c2a 100644 --- a/src/menus-misc.c +++ b/src/menus-misc.c @@ -316,8 +316,7 @@ FillFlatFileMenu(Menu * m, const char *file) if ((act) && (!strcmp(act, "exec")) && (params)) { - sscanf(params, "%4000s", wd); - if (path_canexec(wd)) + if (path_canexec0(params)) { Esnprintf(wd, sizeof(wd), "exec %s", params); mi = MenuItemCreate(txt, icon, wd, NULL); diff --git a/src/menus.c b/src/menus.c index ba693234..359801c4 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1846,10 +1846,7 @@ MenuConfigLoad(FILE * fs) /* if its an execute line then check to see if the exec is * on your system before adding the menu entry */ if (!strcmp(s2, "exec")) - { - sscanf(p3, "%1000s", s3); - ok = path_canexec(s3); - } + ok = path_canexec0(p3); if (ok) { mi = MenuItemCreate(txt, icon, p2, NULL);