mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 06:06:32 +00:00
toolchain/wrapper: use the {str, len} tuples for the unsafe paths
In 61cb120 (toolchain/wrapper: extend paranoid check to -isystem), we introduced a {str,len} tuple to check the various arguments pased to gcc, to avoid hard-coding an ever-growing, long list of those args directly in the condition check. Now, we're left with a long list of unsafe paths, somehow hidden within the code, which can use the same mechanism we use for arguments. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
31c093e6d0
commit
3eccf76201
@ -98,6 +98,20 @@ struct str_len_s {
|
|||||||
*/
|
*/
|
||||||
#define STR_LEN(s) { #s, sizeof(#s)-1 }
|
#define STR_LEN(s) { #s, sizeof(#s)-1 }
|
||||||
|
|
||||||
|
/* List of paths considered unsafe for cross-compilation.
|
||||||
|
*
|
||||||
|
* An unsafe path is one that points to a directory with libraries or
|
||||||
|
* headers for the build machine, which are not suitable for the target.
|
||||||
|
*/
|
||||||
|
static const struct str_len_s unsafe_paths[] = {
|
||||||
|
STR_LEN(/lib),
|
||||||
|
STR_LEN(/usr/include),
|
||||||
|
STR_LEN(/usr/lib),
|
||||||
|
STR_LEN(/usr/local/include),
|
||||||
|
STR_LEN(/usr/local/lib),
|
||||||
|
{ NULL, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
/* Unsafe options are options that specify a potentialy unsafe path,
|
/* Unsafe options are options that specify a potentialy unsafe path,
|
||||||
* that will be checked by check_unsafe_path(), below.
|
* that will be checked by check_unsafe_path(), below.
|
||||||
*/
|
*/
|
||||||
@ -126,13 +140,10 @@ static void check_unsafe_path(const char *arg,
|
|||||||
int paranoid,
|
int paranoid,
|
||||||
int arg_has_path)
|
int arg_has_path)
|
||||||
{
|
{
|
||||||
char **c;
|
const struct str_len_s *p;
|
||||||
static char *unsafe_paths[] = {
|
|
||||||
"/lib", "/usr/include", "/usr/lib", "/usr/local/include", "/usr/local/lib", NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (c = unsafe_paths; *c != NULL; c++) {
|
for (p=unsafe_paths; p->str; p++) {
|
||||||
if (strncmp(path, *c, strlen(*c)))
|
if (strncmp(path, p->str, p->len))
|
||||||
continue;
|
continue;
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: %s: unsafe header/library path used in cross-compilation: '%s%s%s'\n",
|
"%s: %s: unsafe header/library path used in cross-compilation: '%s%s%s'\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user