Package: file
Version: 4.26-2
Severity: normal

file normally does sensible things with an empty file, e.g.

$ touch empty; file empty
empty: empty
$ file - < empty
/dev/stdin: empty

but produces a confusing error message if you try to feed it an empty
file via a pipe:

$ cat empty | file
/dev/stdin: no read permission

I find this difference in strace logs suggestive:

-fstat(0, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
+fstat(0, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
 read(0, ""..., 98304)                   = 0
+access(NULL, W_OK)                      = -1 EFAULT (Bad address)
+access(NULL, X_OK)                      = -1 EFAULT (Bad address)
-write(1, "/dev/stdin: empty\n"..., 18)  = 18
+write(1, "/dev/stdin: no read permission\n"..., 31) = 31

I don't know what file is trying to do here (and I note that it is
almost always wrong to use access()), but perhaps it is assuming that a
failure of access() must be because of a lack of permissions, ignoring the
possibility of a bad pointer ...  I see it call access() with a sensible
pathname if I try to use it on /etc/shadow from an unprivileged account;
this also seems wrong -- it should take the EACCES result from the open()
as authoritative -- but that might give some clues where things are going
wrong in the code.

-- System Information:
Debian Release: 5.0
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages file depends on:
ii  libc6                  2.7-16            GNU C Library: Shared libraries
ii  libmagic1              4.26-2            File type determination library us
ii  zlib1g                 1:1.2.3.3.dfsg-12 compression library - runtime

file recommends no packages.

file suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to