diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index c6748b16723..a3419003e2b 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -577,7 +577,18 @@ private: } if (!history_file.empty() && !fs::exists(history_file)) - FS::createFile(history_file); + { + /// Avoid TOCTOU issue. + try + { + FS::createFile(history_file); + } + catch (const ErrnoException & e) + { + if (e.getErrno() != EEXIST) + throw; + } + } LineReader::Patterns query_extenders = {"\\"}; LineReader::Patterns query_delimiters = {";", "\\G"}; diff --git a/tests/queries/0_stateless/01921_test_progress_bar.py b/tests/queries/0_stateless/01921_test_progress_bar.py index 8e917d4cc46..a95d5994607 100755 --- a/tests/queries/0_stateless/01921_test_progress_bar.py +++ b/tests/queries/0_stateless/01921_test_progress_bar.py @@ -12,9 +12,8 @@ log = None # uncomment the line below for debugging #log=sys.stdout -with client(name='client1>', log=log) as client1, client(name='client2>', log=log) as client2: +with client(name='client1>', log=log) as client1: client1.expect(prompt) client1.send('SELECT number FROM numbers(100) FORMAT Null') client1.expect('Progress: 100\.00 rows, 800\.00 B.*' + end_of_block) - # 0 rows becuase Format Null. client1.expect('0 rows in set. Elapsed: [\\w]{1}\.[\\w]{3} sec.' + end_of_block)