summaryrefslogtreecommitdiff
path: root/src/configure.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2023-01-14 18:14:03 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2023-01-14 18:14:03 +0100
commitd37076a33296877fee3154db689f2990785aed94 (patch)
tree32a5eac40012a92c05eea81d401147b00fe18bef /src/configure.cc
parent8a7f76e7a1b404dc7f703d09d724defaee9e4238 (diff)
Escape all user-input strings when writing configuration.cc
Diffstat (limited to 'src/configure.cc')
-rw-r--r--src/configure.cc29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/configure.cc b/src/configure.cc
index 8e88092..3bb2d48 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -16,6 +16,7 @@
#include "rebuild.h"
#include "externals.h"
#include "tools.h"
+#include "util.h"
std::filesystem::path configurationFile("configuration.cc");
std::filesystem::path configHeaderFile("config.h");
@@ -495,38 +496,38 @@ int regenerateCache(ctor::settings& settings,
istr << " .args = {";
for(const auto& arg : args)
{
- istr << "\"" << arg << "\",";
+ istr << "\"" << esc(arg) << "\",";
}
istr << "},\n";
istr << " .env = {";
for(const auto& e : env)
{
- istr << "{\"" << e.first << "\", \"" << e.second << "\"}, ";
+ istr << "{\"" << esc(e.first) << "\", \"" << esc(e.second) << "\"}, ";
}
istr << "},\n";
istr << " .tools = {\n";
if(!builddir.empty())
{
- istr << " { \"" << ctor::cfg::builddir << "\", \"" << builddir << "\" },\n";
+ istr << " { \"" << ctor::cfg::builddir << "\", \"" << esc(builddir) << "\" },\n";
ctor::builddir = builddir;
}
- istr << " { \"" << ctor::cfg::host_cc << "\", \"" << host_cc << "\" },\n";
- istr << " { \"" << ctor::cfg::host_cxx << "\", \"" << host_cxx << "\" },\n";
- istr << " { \"" << ctor::cfg::host_ar << "\", \"" << host_ar << "\" },\n";
- istr << " { \"" << ctor::cfg::host_ld << "\", \"" << host_ld << "\" },\n";
- istr << " { \"" << ctor::cfg::build_cc << "\", \"" << build_cc << "\" },\n";
- istr << " { \"" << ctor::cfg::build_cxx << "\", \"" << build_cxx << "\" },\n";
- istr << " { \"" << ctor::cfg::build_ar << "\", \"" << build_ar << "\" },\n";
- istr << " { \"" << ctor::cfg::build_ld << "\", \"" << build_ld << "\" },\n";
+ istr << " { \"" << ctor::cfg::host_cc << "\", \"" << esc(host_cc) << "\" },\n";
+ istr << " { \"" << ctor::cfg::host_cxx << "\", \"" << esc(host_cxx) << "\" },\n";
+ istr << " { \"" << ctor::cfg::host_ar << "\", \"" << esc(host_ar) << "\" },\n";
+ istr << " { \"" << ctor::cfg::host_ld << "\", \"" << esc(host_ld) << "\" },\n";
+ istr << " { \"" << ctor::cfg::build_cc << "\", \"" << esc(build_cc) << "\" },\n";
+ istr << " { \"" << ctor::cfg::build_cxx << "\", \"" << esc(build_cxx) << "\" },\n";
+ istr << " { \"" << ctor::cfg::build_ar << "\", \"" << esc(build_ar) << "\" },\n";
+ istr << " { \"" << ctor::cfg::build_ld << "\", \"" << esc(build_ld) << "\" },\n";
if(!ctor_includedir.empty())
{
- istr << " { \"" << ctor::cfg::ctor_includedir << "\", \"" << ctor_includedir << "\" },\n";
+ istr << " { \"" << ctor::cfg::ctor_includedir << "\", \"" << esc(ctor_includedir) << "\" },\n";
ctor::includedir = ctor_includedir;
}
if(!ctor_libdir.empty())
{
- istr << " { \"" << ctor::cfg::ctor_libdir << "\", \"" << ctor_libdir << "\" },\n";
+ istr << " { \"" << ctor::cfg::ctor_libdir << "\", \"" << esc(ctor_libdir) << "\" },\n";
ctor::libdir = ctor_libdir;
}
@@ -535,7 +536,7 @@ int regenerateCache(ctor::settings& settings,
for(const auto& ext : externalConfigs)
{
- istr << " { \"" << ext.name << "\", {\n";
+ istr << " { \"" << esc(ext.name) << "\", {\n";
ctor::flags resolved_flags;
if(std::holds_alternative<ctor::external_manual>(ext.external))
{