From 18dad130fa715196adb171f69395110a2d013f51 Mon Sep 17 00:00:00 2001 From: Packit Date: Sep 09 2020 16:28:23 +0000 Subject: Apply patch 0013-xtables-restore-fix-for-noflush-and-empty-lines.patch patch_name: 0013-xtables-restore-fix-for-noflush-and-empty-lines.patch present_in_specfile: true location_in_specfile: 13 --- diff --git a/iptables/tests/shell/testcases/ipt-restore/0011-noflush-empty-line_0 b/iptables/tests/shell/testcases/ipt-restore/0011-noflush-empty-line_0 new file mode 100755 index 0000000..bea1a69 --- /dev/null +++ b/iptables/tests/shell/testcases/ipt-restore/0011-noflush-empty-line_0 @@ -0,0 +1,16 @@ +#!/bin/bash -e + +# make sure empty lines won't break --noflush + +cat <in)) { size_t blen = strlen(buffer); - /* drop trailing newline; xtables_restore_parse_line() + /* Drop trailing newline; xtables_restore_parse_line() * uses strtok() which replaces them by nul-characters, * causing unpredictable string delimiting in - * preload_buffer */ - if (buffer[blen - 1] == '\n') + * preload_buffer. + * Unless this is an empty line which would fold into a + * spurious EoB indicator (double nul-char). */ + if (buffer[blen - 1] == '\n' && blen > 1) buffer[blen - 1] = '\0'; else blen++;