diff --git a/.cirrus.yml b/.cirrus.yml index 265104d..9a7f2ba 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,50 +4,11 @@ task: only_if: $CIRRUS_BRANCH == "main" || $CIRRUS_PR != "" matrix: - - name: Linux, GCC, no GTK - container: - image: gcc:15.1 - environment: - DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined -fuse-ld=gold - # $LANG and $LC_* are not set by default in this images, so force - # $LC_ALL to make `man` work correctly - LC_ALL: C - UBSAN_OPTIONS: print_stacktrace=1 - install_script: apt-get update -y && apt-get install --no-install-recommends -y cmake libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev man-db python3-pexpect python3-pytest xxd - test_script: uname -sr && python3 --version && mkdir build && cd build && cmake -DENABLE_GUI=OFF .. && cmake --build . && cmake --build . -- check && cmake --build . -- install - - - name: Linux, GCC, GTK 2 - container: - image: gcc:15.1 - environment: - DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined -fuse-ld=gold -Wno-deprecated-declarations - # $LANG and $LC_* are not set by default in this images, so force - # $LC_ALL to make `man` work correctly - LC_ALL: C - UBSAN_OPTIONS: print_stacktrace=1 - install_script: apt-get update -y && apt-get install --no-install-recommends -y cmake libgtk2.0-dev libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev libxtst-dev man-db python3-pexpect python3-pytest xxd - test_script: uname -sr && python3 --version && mkdir build && cd build && cmake .. && cmake --build . && cmake --build . -- check && cmake --build . -- install - - - name: Linux, GCC, GTK 3 - container: - image: gcc:15.1 - environment: - DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined -fuse-ld=gold -Wno-deprecated-declarations - # $LANG and $LC_* are not set by default in this images, so force - # $LC_ALL to make `man` work correctly - LC_ALL: C - UBSAN_OPTIONS: print_stacktrace=1 - install_script: apt-get update -y && apt-get install --no-install-recommends -y cmake libgtk-3-dev libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev libxtst-dev man-db python3-pexpect python3-pytest xxd - test_script: uname -sr && python3 --version && mkdir build && cd build && cmake .. && cmake --build . && cmake --build . -- check && cmake --build . -- install - - name: macOS macos_instance: image: ghcr.io/cirruslabs/macos-runner:sequoia environment: - CFLAGS: -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/include + CFLAGS: -pedantic -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/include LDFLAGS: -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/lib PKG_CONFIG_PATH: /opt/homebrew/opt/openssl@3/lib/pkgconfig install_script: brew update && brew install json-c libscrypt openssl python3 && env PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip install pexpect pytest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 274804a..27afd79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,9 +26,69 @@ jobs: cd wd git fetch -- origin ${{ github.event.pull_request.head.sha }} git checkout FETCH_HEAD - export CFLAGS="-Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined" + export CFLAGS="-pedantic -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined" export UBSAN_OPTIONS=print_stacktrace=1 cmake -DENABLE_GUI=OFF -B build -S . cmake --build build cmake --build build --target check cmake --install build + + ubuntu2404_nogui: + name: Ubuntu 24.04, no GTK + runs-on: ubuntu-24.04 + env: + DEBIAN_FRONTEND: noninteractive + CFLAGS: -pedantic -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + UBSAN_OPTIONS: print_stacktrace=1 + steps: + - run: uname -rms + - run: python3 --version + - run: sudo apt-get update + - run: sudo apt-get install --no-install-recommends -y cmake libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev python3-pexpect python3-pytest xxd + - run: echo "cloning ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" + - run: git clone --no-checkout -- ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} wd + - run: cd wd && git fetch -- origin ${{ github.event.pull_request.head.sha }} && git checkout FETCH_HEAD + - run: cmake -DENABLE_GUI=OFF -B build -S wd + - run: cmake --build build + - run: cmake --build build --target check + - run: sudo cmake --install build + + ubuntu2404_gtk2: + name: Ubuntu 24.04, GTK 2 + runs-on: ubuntu-24.04 + env: + DEBIAN_FRONTEND: noninteractive + CFLAGS: -pedantic -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + UBSAN_OPTIONS: print_stacktrace=1 + steps: + - run: uname -rms + - run: python3 --version + - run: sudo apt-get update + - run: sudo apt-get install --no-install-recommends -y cmake libgtk2.0-dev libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev libxtst-dev python3-pexpect python3-pytest xxd + - run: echo "cloning ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" + - run: git clone --no-checkout -- ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} wd + - run: cd wd && git fetch -- origin ${{ github.event.pull_request.head.sha }} && git checkout FETCH_HEAD + - run: cmake -B build -S wd + - run: cmake --build build + - run: cmake --build build --target check + - run: sudo cmake --install build + + ubuntu2404_gtk3: + name: Ubuntu 24.04, GTK 3 + runs-on: ubuntu-24.04 + env: + DEBIAN_FRONTEND: noninteractive + CFLAGS: -pedantic -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + UBSAN_OPTIONS: print_stacktrace=1 + steps: + - run: uname -rms + - run: python3 --version + - run: sudo apt-get update + - run: sudo apt-get install --no-install-recommends -y cmake libgtk-3-dev libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev libxtst-dev python3-pexpect python3-pytest xxd + - run: echo "cloning ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" + - run: git clone --no-checkout -- ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} wd + - run: cd wd && git fetch -- origin ${{ github.event.pull_request.head.sha }} && git checkout FETCH_HEAD + - run: cmake -B build -S wd + - run: cmake --build build + - run: cmake --build build --target check + - run: sudo cmake --install build diff --git a/cli/main.c b/cli/main.c index a06dd96..ca7ec05 100644 --- a/cli/main.c +++ b/cli/main.c @@ -194,8 +194,8 @@ static void discard_entries(passwand_entry_t **entries, size_t *entry_len) { // not need the state parameter static void entry_trampoline(void *state, const char *space, const char *key, const char *value) { - void (*f)(const char *, const char *, const char *) = state; - f(space, key, value); + const command_t *const cmd = state; + cmd->loop_body(space, key, value); } typedef struct { @@ -231,8 +231,9 @@ static void *thread_loop(void *arg) { break; if (command->loop_body != NULL) { - passwand_error_t err = passwand_entry_do( - ts->main, &ts->entries[index], entry_trampoline, command->loop_body); + passwand_error_t err = + passwand_entry_do(ts->main, &ts->entries[index], entry_trampoline, + (command_t *)command); if (err != PW_OK) { eprint("failed to handle entry %zu: %s\n", index, passwand_error(err)); ret = (void *)-1; diff --git a/gui/gui.h b/gui/gui.h index 738fe31..6a968e2 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -3,10 +3,12 @@ #include static inline bool supported_lower(char c) { + if (c >= 'a' && c <= 'z') + return true; + if (c >= '0' && c <= '9') + return true; switch (c) { - case 'a' ... 'z': case '`': - case '0' ... '9': case '-': case '=': case '[': @@ -24,8 +26,9 @@ static inline bool supported_lower(char c) { } static inline bool supported_upper(char c) { + if (c >= 'A' && c <= 'Z') + return true; switch (c) { - case 'A' ... 'Z': case '~': case '!': case '@':