Skip to content

Non-portable regression caused by 25fee28c/#879011

Reposting from: https://lists.reproducible-builds.org/pipermail/diffoscope/2020-March/002632.html

Folks,

I started using diffoscope on FreeBSD to aid Hervé Boutemy's work for Maven reproducibility. I have noticed that 25fee28c uses a non-portable approach by utilizing the /dev/stdin symlink. zipinfo exits with 9. I have described the problem with /dev/stdin in detail here, and about its non-portability.

The upshot is:

  • /dev/stdin is not POSIX
  • It may not behave the way you expect
  • unzip explicitly does not support pipe or character devices:
   Archives read from standard input are not yet supported, except with
   funzip (and then only the first member of the archive can be
   extracted).
  • When you read the source code you'll see that stat(2) output is not checked for regular file and it queries the stat struct for st_size is is 0 for streams like pipes or character devices.
  • It maybe some special feature of Linux/glibc to replace the stat information of /dev/stdin of the file read, but that is, imho, highly questionable.

The attached patch solves the problem for me. I don't want to live with downstream patch forever. Please consider upstreaming it

0001-Restore-portability-of-zipinfo-call-caused-by-a-regr.patch

Edited by Michael Osipov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information