Browse Source

Guard the file protocol against the Windows menu macro

master
evgeny 6 days ago
parent
commit
e9e38ee029
  1. 8
      tests/test_member_files.c

8
tests/test_member_files.c

@ -1,5 +1,9 @@
/* Протокол и настоящее дисковое хранилище: атомарность, случайные диапазоны,
* версии, квота, повторы, ссылки и закрытие дескрипторов через 10 секунд. */
#ifndef _WIN32
/* На Linux тоже воспроизводим пространство имён Win32 до подключения протокола. */
#define MF_REMOVE 0x00001000L
#endif
#include "../src/member_files/storage.h"
#include "../src/member_files/disk.h"
#include "../src/member_files/worker.h"
@ -22,6 +26,10 @@ static void run(struct mf_storage* s, uint64_t group, uint64_t peer, int command
}
static void protocol_test(void) {
EXPECT(MF_REMOVE_PATH == 10, "remove command preserves wire code 10");
#ifdef MF_REMOVE
EXPECT(MF_REMOVE == 0x00001000L, "protocol preserves the Win32 menu flag");
#endif
static const char* invalid[] = { "../x", "a/../b", "/x", "a\\b", "a//b", "a/", "a/.x", "CON", "con.txt", "LPT1", "x:", "a ", "\xc0\xaf", "\xed\xa0\x80" };
for (unsigned i = 0; i < sizeof(invalid) / sizeof(invalid[0]); i++) EXPECT(!mf_path_valid(invalid[i], 0), invalid[i]);
EXPECT(mf_path_valid("Документы/пример.webp", 0), "UTF-8 path");

Loading…
Cancel
Save