From fb25bdc7b7727e4db7fad0fc385d4dbf5a592553 Mon Sep 17 00:00:00 2001 From: K900 Date: Tue, 26 Mar 2024 10:55:15 +0300 Subject: [PATCH] build-remote: fix format string shenanigans HintFmt(string) invokes the HintFmt("%s", literal) constructor, which is not what we want here. Add a constructor with a proper name and call that. Next step: rename all the other ones to HintFmt::literal(string). Fixes https://github.com/NixOS/nix/issues/10238 (cherry picked from commit 2d4edb945bc02c074a922bfa3f38cbf21976728b) --- src/build-remote/build-remote.cc | 2 +- src/libutil/fmt.hh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index 118468477..18eee830b 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -202,7 +202,7 @@ static int main_build_remote(int argc, char * * argv) else drvstr = ""; - auto error = HintFmt(errorText); + auto error = HintFmt::fromFormatString(errorText); error % drvstr % neededSystem diff --git a/src/libutil/fmt.hh b/src/libutil/fmt.hh index abbaf95b6..c178257d4 100644 --- a/src/libutil/fmt.hh +++ b/src/libutil/fmt.hh @@ -144,6 +144,10 @@ public: : HintFmt("%s", Uncolored(literal)) { } + static HintFmt fromFormatString(const std::string & format) { + return HintFmt(boost::format(format)); + } + /** * Interpolate the given arguments into the format string. */