diff options
author | Martin Pool <mbp@sourcefrog.net> | 2025-01-25 07:53:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-25 07:53:41 -0800 |
commit | 66bf4c56f6af2243c48748139c078f4f01cd639b (patch) | |
tree | 7c250548b2a2f4a597290aeea19f5653d084ef8e /src/serve.c | |
parent | 324f752f3fa30f15a44463b683c56f61c66bb3b4 (diff) | |
parent | e873874d49ddc22a5f2d1049d601944e18980556 (diff) |
Merge pull request #531 from wzssyqa/spec-optionHEADorigin/masterorigin/HEADmaster
Add sysroot option and allow -specs option from compiler
Diffstat (limited to 'src/serve.c')
-rw-r--r-- | src/serve.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/serve.c b/src/serve.c index 7dd4647..e3a3b75 100644 --- a/src/serve.c +++ b/src/serve.c @@ -70,6 +70,8 @@ #include <sys/socket.h> #include <sys/time.h> +#include <alloca.h> + #include "distcc.h" #include "trace.h" #include "util.h" @@ -768,11 +770,27 @@ static int dcc_run_job(int in_fd, on securing https://godbolt.org/ */ char *a; int i; - for (i = 0; (a = argv[i]); i++) - if (strncmp(a, "-fplugin=", strlen("-fplugin=")) == 0 || - strncmp(a, "-specs=", strlen("-specs=")) == 0) { - rs_log_warning("-fplugin= and/or -specs= passed, which are insecure and not supported."); + for (i = 0; (a = argv[i]); i++) { + if (strncmp(a, "-fplugin=", strlen("-fplugin=")) == 0) { + rs_log_warning("-fplugin= passed, which are insecure and not supported."); goto out_cleanup; + } + if (strncmp(a, "-specs=", strlen("-specs=")) == 0) { + int fail = 1; + if (arg_sysroot) { + char *spec_file = strchr(a, '=') + 1; + char *spec_path = alloca(strlen(spec_file) + strlen(arg_sysroot) + 8); + sprintf(spec_path, "%s/%s", arg_sysroot, spec_file); + struct stat spec_stat; + if (stat(spec_path, &spec_stat) != -1 && (spec_stat.st_mode & S_IFMT) == S_IFREG) { + fail = 0; + } + } + if (fail) { + rs_log_warning("-specs= passed, but we cannot find the specs."); + goto out_cleanup; + } + } } if ((compile_ret = dcc_spawn_child(argv, &cc_pid, |