mirror of
https://github.com/NixOS/nix
synced 2025-07-07 22:33:57 +02:00
fix(libmain/common-args): do not exceed maximum allowed verbosity
This patch gets rid of UB when verbosity exceeds the maximum logging value of `lvlVomit = 7` and
reaches invalid values (e.g. 8). This is actually triggered in functional tests.
There are too many occurrences to list, but here's one from the UBSAN log:
../src/libstore/gc.cc:610:5: runtime error: load of value 8, which is not a valid value for type 'Verbosity'
(cherry picked from commit b9f8c4af40
)
This commit is contained in:
parent
e0c8b0fc4f
commit
dea80c4fec
1 changed files with 3 additions and 1 deletions
|
@ -17,7 +17,9 @@ MixCommonArgs::MixCommonArgs(const std::string & programName)
|
||||||
.shortName = 'v',
|
.shortName = 'v',
|
||||||
.description = "Increase the logging verbosity level.",
|
.description = "Increase the logging verbosity level.",
|
||||||
.category = loggingCategory,
|
.category = loggingCategory,
|
||||||
.handler = {[]() { verbosity = (Verbosity) (verbosity + 1); }},
|
.handler = {[]() {
|
||||||
|
verbosity = (Verbosity) std::min<std::underlying_type_t<Verbosity>>(verbosity + 1, lvlVomit);
|
||||||
|
}},
|
||||||
});
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue