regex: incorrect REG_EMPTY

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Sun Jun 10 09:00:00 GMT 2012


I encountered an apparent bug in our regex code triggered by one of the 
included hostprogs (namely arch/x86/tools/relocs.c) used while 
cross-compiling an i386 Linux kernel.

The exact regexp in question is included in the attached STC:

$ gcc -Wall regex-test.c  && ./a
./a: empty (sub)expression

$ gcc -DPCRE -Wall regex-test.c -lpcreposix && ./a


Yaakov
-------------- next part --------------
#ifdef PCRE
#include <pcreposix.h>
#else
#include <regex.h>
#endif
#include <error.h>

int
main(void)
{
  regex_t re;
  int ret;
  char errbuf[128];
  /* offending regex pattern from kernel:arch/x86/tools/relocs.c */
  const char pattern[] = "^(__init_(begin|end)|"
        "__x86_cpu_dev_(start|end)|"
        "(__parainstructions|__alt_instructions)(|_end)|"
        "(__iommu_table|__apicdrivers|__smp_locks)(|_end)|"
        "__(start|end)_pci_.*|"
        "__(start|end)_builtin_fw|"
        "__(start|stop)___ksymtab(|_gpl|_unused|_unused_gpl|_gpl_future)|"
        "__(start|stop)___kcrctab(|_gpl|_unused|_unused_gpl|_gpl_future)|"
        "__(start|stop)___param|"
        "__(start|stop)___modver|"
        "__(start|stop)___bug_table|"
        "__tracedata_(start|end)|"
        "__(start|stop)_notes|"
        "__end_rodata|"
        "__initramfs_start|"
        "(jiffies|jiffies_64)|"
        "_end)$";

  if ((ret = regcomp (&re, pattern, REG_EXTENDED|REG_NOSUB)))
    {
      regerror(ret, &re, errbuf, sizeof(errbuf));
      error(ret, 0, errbuf);
    }
  return 0;
}

-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list