Subject: bug#75924: maint: fix s390 buffer flushes

From: Andreas Hasenack <[email-masked]>
Date: Wed, 29 Jan 2025 16:16:27 -0300

Hi,

the s390x build of gzip 1.12 with this patch applied failed[1] due to
a test failure:

FAIL: hufts
===========

+ initial_cwd_=/<<PKGBUILDDIR>>/builddir/tests
+ testdir_prefix_
+ printf gt
+ pfx_=gt
+ mktempd_ /<<PKGBUILDDIR>>/builddir/tests gt-hufts.XXXX
+ destdir_=/<<PKGBUILDDIR>>/builddir/tests
+ template_=gt-hufts.XXXX
+ MAX_TRIES_=4
+ destdir_slash_=/<<PKGBUILDDIR>>/builddir/tests/
+ unset TMPDIR
+ d=/<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ :
+ test -d /<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ ls -dgo /<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ perms=drwx------ 2 4096 Jan 29 19:11
/<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ :
+ echo /<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ return
+ test_dir_=/<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ cd /<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ srcdir=../../../tests
+ builddir=..
+ export srcdir builddir
+ gl_init_sh_nl_=

+ IFS=

+ expr 1 + 128
+ eval trap 'Exit 129' 1
+ trap Exit 129 1
+ expr 2 + 128
+ eval trap 'Exit 130' 2
+ trap Exit 130 2
+ expr 3 + 128
+ eval trap 'Exit 131' 3
+ trap Exit 131 3
+ expr 13 + 128
+ eval trap 'Exit 141' 13
+ trap Exit 141 13
+ expr 15 + 128
+ eval trap 'Exit 143' 15
+ trap Exit 143 15
+ saved_IFS=

+ IFS=:
+ new_PATH=
+ sep_=
+ test -d /<<PKGBUILDDIR>>/builddir/.
+ new_PATH=/<<PKGBUILDDIR>>/builddir
+ sep_=:
+ test -d /usr/local/sbin/.
+ new_PATH=/<<PKGBUILDDIR>>/builddir:/usr/local/sbin
+ sep_=:
+ test -d /usr/local/bin/.
+ new_PATH=/<<PKGBUILDDIR>>/builddir:/usr/local/sbin:/usr/local/bin
+ sep_=:
+ test -d /usr/sbin/.
+ new_PATH=/<<PKGBUILDDIR>>/builddir:/usr/local/sbin:/usr/local/bin:/usr/sbin
+ sep_=:
+ test -d /usr/bin/.
+ new_PATH=/<<PKGBUILDDIR>>/builddir:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
+ sep_=:
+ test -d /sbin/.
+ new_PATH=/<<PKGBUILDDIR>>/builddir:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin
+ sep_=:
+ test -d /bin/.
+ new_PATH=/<<PKGBUILDDIR>>/builddir:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ sep_=:
+ test -d /usr/games/.
+ new_PATH=/<<PKGBUILDDIR>>/builddir:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ sep_=:
+ IFS=

+ PATH=/<<PKGBUILDDIR>>/builddir:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ export PATH
+ trap remove_tmp_ 0
+ path_prepend_ ..
+ test 1 != 0
+ path_dir_=..
+ abs_path_dir_=/<<PKGBUILDDIR>>/builddir/tests/..
+ PATH=/<<PKGBUILDDIR>>/builddir/tests/..:/<<PKGBUILDDIR>>/builddir:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ create_exe_shims_ /<<PKGBUILDDIR>>/builddir/tests/..
+ return 0
+ shift
+ test 0 != 0
+ export PATH
+ printf \n...: invalid compressed data--format violated\n
+ fail=0
+ returns_ 1 gzip -dc /<<PKGBUILDDIR>>/builddir/../tests/hufts-segv.gz
+ compare /dev/null out
+ compare_dev_null_ /dev/null out
+ test 2 = 2
+ test x/dev/null = x/dev/null
+ test -s out
+ return 0
+ return 0
+ clean_stderr=
  s/.*hufts-segv.gz: /...: /
  /^+/d
  /Operation-Ending-Supplemental Code/d

+ sed
  s/.*hufts-segv.gz: /...: /
  /^+/d
  /Operation-Ending-Supplemental Code/d
 err-raw
+ compare exp err
+ compare_dev_null_ exp err
+ test 2 = 2
+ test xexp = x/dev/null
+ test xerr = x/dev/null
+ return 2
+ compare_ exp err
+ diff -u exp err
+ printf \037\213\010\000\060\060\060\060\060\060\144\000\000\000
+ printf \ngzip: stdin: invalid compressed data--format violated\n
+ returns_ 1 gzip -d
+ sed
  s/.*hufts-segv.gz: /...: /
  /^+/d
  /Operation-Ending-Supplemental Code/d
 err33501-raw
+ compare exp33501 err33501
+ compare_dev_null_ exp33501 err33501
+ test 2 = 2
+ test xexp33501 = x/dev/null
+ test xerr33501 = x/dev/null
+ return 2
+ compare_ exp33501 err33501
+ diff -u exp33501 err33501
--- exp33501 2025-01-29 19:11:54.875303836 +0000
+++ err33501 2025-01-29 19:11:54.875303836 +0000
@@ -1,2 +1,2 @@

-gzip: stdin: invalid compressed data--format violated
+gzip: stdin: unexpected end of file
+ fail=1
+ Exit 1
+ set +e
+ exit 1
+ exit 1
+ remove_tmp_
+ __st=1
+ cleanup_
+ :
+ test  = yes
+ cd /<<PKGBUILDDIR>>/builddir/tests
+ chmod -R u+rwx /<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ rm -rf /<<PKGBUILDDIR>>/builddir/tests/gt-hufts.whyU
+ exit 1
FAIL hufts (exit status: 1)

============================================================================
Testsuite summary for gzip 1.12
============================================================================
# TOTAL: 26
# PASS:  25
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

1. https://launchpadlibrarian.net/773464868/buildlog_ubuntu-plucky-s390x.gzip_1.12-1.1ubuntu3~ppa1_BUILDING.txt.gz

On Wed, Jan 29, 2025 at 3:59 PM Paul Eggert <[email-masked]> wrote:
>
> Thanks for the bug report. I installed the attached, a bit simpler than
> the patch you suggested; can you please give it a try?
>
> Also, is there a related bug near dfltcc.c line 375? That is, when
> (inptr == insize && fill_inbuf (1) == EOF && param->cf), won't insize
> then be zero, so that gzip will go into an infinite loop attempting to
> read past EOF?