Skip to content

Commit e3d734c

Browse files
committed
Fix SM-serialization testcase
`xmpp_run_once()` uses `FD_SET()` to determine which sockets to `select()` on. The socket gets initialized to `INVALID_SOCKET = -1` inside `xmpp_conn_new()` which leads to a buffer overflow once `FD_SET()` is called. This is only exposed when enabling a higher optimization level, which was only done in the `release-test` CI job. * Fix this testcase by initializing the socket to a possible value. * Build the Valgrind CI jobs with `-O2`. * Make the output of the `release-test` more verbose. Signed-off-by: Steffen Jaeckel <[email protected]>
1 parent e7b08fa commit e3d734c

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
strategy:
1515
matrix:
1616
valgrind:
17-
- { configure: '' , make: 'check' }
18-
- { configure: '--enable-valgrind' , make: 'check-valgrind' }
17+
- { configure: '' , cflags: '', make: 'check' }
18+
- { configure: '--enable-valgrind' , cflags: '-O2', make: 'check-valgrind' }
1919
options:
2020
- { configure: '' }
2121
- { configure: '--without-libxml2' }
@@ -35,7 +35,7 @@ jobs:
3535
- name: Build the library
3636
run: |
3737
./bootstrap.sh
38-
./configure ${{ matrix.options.configure }} ${{ matrix.valgrind.configure }} CFLAGS="-Werror -g3"
38+
./configure ${{ matrix.options.configure }} ${{ matrix.valgrind.configure }} CFLAGS="-Werror -g3 ${{ matrix.valgrind.cflags }}"
3939
make -j$(nproc)
4040
- name: Run tests
4141
run: |
@@ -135,6 +135,11 @@ jobs:
135135
if: ${{ !failure() }}
136136
run: |
137137
cat testbuild.log
138+
- name: Error logs
139+
if: ${{ failure() }}
140+
run: |
141+
cat testbuild.log || true
142+
cat testerr.log || true
138143
139144
code-style:
140145
runs-on: ubuntu-20.04

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ examples/roster
4646
examples/uuid
4747
examples/vcard
4848
testbuild*.log
49+
testerr*.log
4950
test-release/
5051
test_stamp
5152
test-suite*.log

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ dist-archives:
333333

334334
test-release: dist
335335
@touch testbuild-$(PACKAGE_VERSION).log && ln -sf testbuild-$(PACKAGE_VERSION).log testbuild.log
336+
@touch testerr-$(PACKAGE_VERSION).log && ln -sf testerr-$(PACKAGE_VERSION).log testerr.log
336337
@mkdir -p test-release && cp $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.* test-release && pushd test-release && \
337338
tar xzf $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz && pushd $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && ./testbuild.sh && popd && rm -rf $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) && \
338339
echo "Success" && popd

testbuild.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/bin/sh
22

33
logfile="../../testbuild.log"
4+
errfile="../../testerr.log"
45

56
err_out() {
67
tail $logfile
78
exit 1
89
}
910

1011
./bootstrap.sh
11-
./configure >> $logfile || err_out
12-
make -j$(( `nproc` * 2 + 1 )) >> $logfile || err_out
13-
make check >> $logfile || err_out
12+
./configure >> $logfile 2>> $errfile || err_out
13+
make -j$(( `nproc` * 2 + 1 )) >> $logfile 2>> $errfile || err_out
14+
make check >> $logfile 2>> $errfile || err_out

tests/test_serialize_sm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ int main()
147147
conn->intf = intf;
148148
state = conn->state;
149149
conn->state = XMPP_STATE_CONNECTED;
150+
conn->sock = 123;
150151

151152
xmpp_send_raw(conn, "foo", 3);
152153
ENSURE_EQ(xmpp_conn_send_queue_len(conn), 1);

0 commit comments

Comments
 (0)