Package: grep
Version: 2.5.3~dfsg-6
Severity: normal

Setting the (un-documented) environment variable GREP_USE_DFA to 0
causes
grep to generate incorrect results.

Start with a three line text file:
$ cat file.txt
 foo <= space
        foo <= tab
sfoo

Now use grep with GREP_USE_DFA set to 1.  Notice correct match:
$ GREP_USE_DFA=1 grep '^\s*foo' file.txt
sfoo

Now try with GREP_USE_DFA set to 0.
$ GREP_USE_DFA=0 grep '^\s*foo' file.txt
 foo <= space
        foo <= tab

The program now matches the other two lines, but not the one that
should match.

This is a serious issue since disabling DFA is the default for
multi-byte encodings such as UTF-8.

You can get the same (wrong) results by setting LANG:

$ LANG=C grep '^\s*foo' file.txt
sfoo
$ LANG=en_US.UTF-8 grep '^\s*foo' file.txt
 foo <= space
        foo <= tab

-- System Information:
Debian Release: 5.0.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-amd64 (SMP w/1 CPU core)
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 grep depends on:
ii  libc6                         2.7-18     GNU C Library: Shared
libraries

grep recommends no packages.

grep suggests no packages.

-- no debconf information

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to