fix: bake CI deps into Docker image, fix chunk use_metadata OOB
- Build and push fastsync-ci:v8 with lcov, valgrind, clang baked in - Remove all apt-get install steps from CI (v8 has them pre-installed) - Fix chunk.c use_metadata=true OOB: add remaining_size guard before metadata_from_buf reads past the buffer. The bug allowed network-facing chunk_deserialize to heap-buffer-overflow on crafted inputs. - Also guard against unsigned underflow on remaining_size - sizeof(int)
This commit is contained in:
@@ -5,7 +5,7 @@ on: [push, pull_request]
|
|||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: gitea.tap-tap.win/taptap/fastsync-ci:v7
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v8
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
|
|
||||||
build-and-test:
|
build-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: gitea.tap-tap.win/taptap/fastsync-ci:v7
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v8
|
||||||
needs: lint
|
needs: lint
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
|
|
||||||
sanitizers:
|
sanitizers:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: gitea.tap-tap.win/taptap/fastsync-ci:v7
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v8
|
||||||
needs: lint
|
needs: lint
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -58,15 +58,12 @@ jobs:
|
|||||||
|
|
||||||
fuzz-build:
|
fuzz-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: gitea.tap-tap.win/taptap/fastsync-ci:v7
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v8
|
||||||
needs: lint
|
needs: lint
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install clang
|
|
||||||
run: apt-get update -qq && apt-get install -y -qq clang
|
|
||||||
|
|
||||||
- name: Configure (clang + fuzz)
|
- name: Configure (clang + fuzz)
|
||||||
run: CC=clang CXX=clang++ cmake -B build-fuzz -S . -DENABLE_FUZZ=ON
|
run: CC=clang CXX=clang++ cmake -B build-fuzz -S . -DENABLE_FUZZ=ON
|
||||||
|
|
||||||
@@ -75,15 +72,12 @@ jobs:
|
|||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: gitea.tap-tap.win/taptap/fastsync-ci:v7
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v8
|
||||||
needs: lint
|
needs: lint
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install lcov
|
|
||||||
run: apt-get update -qq && apt-get install -y -qq lcov
|
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: cmake -B build -S . -DENABLE_COVERAGE=ON -DSTRICT_WARNINGS=ON
|
run: cmake -B build -S . -DENABLE_COVERAGE=ON -DSTRICT_WARNINGS=ON
|
||||||
|
|
||||||
@@ -101,15 +95,12 @@ jobs:
|
|||||||
|
|
||||||
valgrind:
|
valgrind:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: gitea.tap-tap.win/taptap/fastsync-ci:v7
|
container: gitea.tap-tap.win/taptap/fastsync-ci:v8
|
||||||
needs: lint
|
needs: lint
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install valgrind
|
|
||||||
run: apt-get update -qq && apt-get install -y -qq valgrind
|
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: cmake -B build -S . -DSTRICT_WARNINGS=ON
|
run: cmake -B build -S . -DSTRICT_WARNINGS=ON
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
FROM ubuntu:24.04
|
FROM ubuntu:24.04
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
gcc g++ make libc6-dev cmake libzstd-dev libssl-dev git ca-certificates curl cppcheck clang-format \
|
gcc g++ make libc6-dev cmake libzstd-dev libssl-dev git ca-certificates curl cppcheck clang-format \
|
||||||
python3 python3-pip python3-venv openssl openssh-client lcov valgrind && \
|
python3 python3-pip python3-venv openssl openssh-client \
|
||||||
|
lcov valgrind clang libclang-rt-18-dev && \
|
||||||
pip3 install --break-system-packages pytest && \
|
pip3 install --break-system-packages pytest && \
|
||||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
||||||
apt-get install -y --no-install-recommends nodejs && \
|
apt-get install -y --no-install-recommends nodejs && \
|
||||||
|
|||||||
+14
-1
@@ -120,10 +120,23 @@ Chunk* chunk_deserialize(Data* data, bool use_metadata) {
|
|||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
if (use_metadata) {
|
if (use_metadata) {
|
||||||
|
if (remaining_size < sizeof(int)) {
|
||||||
|
log_message(LOG_LEVEL_ERROR, "Invalid chunk format: not enough data for metadata");
|
||||||
|
array_list_delete(files);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
file->metadata = metadata_from_buf(&data_pointer);
|
file->metadata = metadata_from_buf(&data_pointer);
|
||||||
remaining_size -= sizeof(int);
|
remaining_size -= sizeof(int);
|
||||||
if (file->metadata)
|
if (file->metadata) {
|
||||||
|
if (remaining_size < FILE_METADATA_WIRE_SIZE) {
|
||||||
|
log_message(LOG_LEVEL_ERROR, "Invalid chunk format: not enough data for metadata body");
|
||||||
|
free(file->metadata);
|
||||||
|
file->metadata = NULL;
|
||||||
|
array_list_delete(files);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
remaining_size -= FILE_METADATA_WIRE_SIZE;
|
remaining_size -= FILE_METADATA_WIRE_SIZE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remaining_size < sizeof(size_t)) {
|
if (remaining_size < sizeof(size_t)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user