From c04da8f90c1db605fc821cce8590810f30a8f011 Mon Sep 17 00:00:00 2001 From: Qiu Yuzhou Date: Sat, 14 Nov 2026 22:31:15 +0800 Subject: [PATCH] fix: restore CodeQL analysis --- .github/workflows/codeql.yml | 24 +++++++++++++++++++ .../Connectivity/ConnectivityRuntime.swift | 6 ++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 66db77e4..45b696a9 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -14,6 +14,30 @@ permissions: security-events: write jobs: + analyze-interpreted: + name: Analyze ${{ matrix.language }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + language: [actions, python] + steps: + - name: Check out source + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Initialize CodeQL + uses: github/codeql-action/init@5895b2c9be147bc7f1c75ce72c5cb577febb1907 # v4 + with: + languages: ${{ matrix.language }} + build-mode: none + + - name: Analyze + uses: github/codeql-action/analyze@5895b2c9be147bc7f1c75ce72c5cb577febb1907 # v4 + with: + category: /language:${{ matrix.language }} + analyze: name: Analyze Swift # CodeQL build tracing does not support macOS 27 or Xcode 27. diff --git a/ShadowsocksX-NG2/App/Application/Connectivity/ConnectivityRuntime.swift b/ShadowsocksX-NG2/App/Application/Connectivity/ConnectivityRuntime.swift index 7b461638..b118945f 100644 --- a/ShadowsocksX-NG2/App/Application/Connectivity/ConnectivityRuntime.swift +++ b/ShadowsocksX-NG2/App/Application/Connectivity/ConnectivityRuntime.swift @@ -218,12 +218,16 @@ struct ConnectivityRuntime { for descriptor in [STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO] { posix_spawn_file_actions_addopen(&actions, descriptor, "/dev/null", O_RDWR, 0) } - let strings = [executable.path, "-c", config.path].map { strdup($0) } + var strings: [UnsafeMutablePointer?] = [] defer { for string in strings { free(string) } } + for argument in [executable.path, "-c", config.path] { + guard let string = strdup(argument) else { throw RuntimeError.failed } + strings.append(string) + } var argv = strings + [nil] var pid: pid_t = 0 let status = argv.withUnsafeMutableBufferPointer {