From: Andreas Schwab <schwab@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: libc-hacker@sources.redhat.com
Subject: Re: Fix regexp compiler with translation table
Date: Wed, 12 May 2004 12:42:00 -0000 [thread overview]
Message-ID: <jen04dddi9.fsf@sykes.suse.de> (raw)
In-Reply-To: <20040512095105.GZ5191@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Wed, 12 May 2004 11:51:05 +0200")
Jakub Jelinek <jakub@redhat.com> writes:
> On Wed, May 12, 2004 at 01:50:34PM +0200, Andreas Schwab wrote:
>> build_wcs_buffer didn't set mbs when a translation table is used. This
>> can result in all kinds of random behaviour during parsing due to use of
>> uninitialized memory.
>>
>> 2004-05-12 Andreas Schwab <schwab@suse.de>
>>
>> * posix/regex_internal.c (build_wcs_buffer): Also set pstr->mbs
>> when translating.
>
> Do you have a testcase? It would be greatly appreciated.
Since it is about uninitialized memory it is hard to test reliably. We
noticed it because "awk -Fbcd '{ print $1 }'" was generating a spurious
error on i686. Here is a reduced test case, although it may not be
minimal, since it took some time until I fully understood the issue.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
#include <locale.h>
#include <time.h>
#define PATTERN "bcd"
char casetable[256];
int
main (void)
{
struct re_pattern_buffer *r1, *r2;
const char *s;
int i;
setlocale (LC_ALL, "");
re_set_syntax (RE_SYNTAX_GNU_AWK);
r1 = malloc (sizeof (*r1));
memset (r1, 0, sizeof (*r1));
r1->fastmap = malloc (256);
s = re_compile_pattern (PATTERN, strlen (PATTERN), r1);
if (s)
{
fprintf (stderr, "%s\n", s);
exit (1);
}
r2 = malloc (sizeof (*r2));
memset (r2, 0, sizeof (*r2));
r2->fastmap = malloc (256);
r2->translate = casetable;
srand (time (0));
for (i = 0; i < 256; i++)
r2->fastmap[i] = rand () % 256;
s = re_compile_pattern (PATTERN, strlen (PATTERN), r2);
if (s)
{
fprintf (stderr, "%s\n", s);
exit (1);
}
exit (0);
}
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2004-05-12 12:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-12 11:52 Andreas Schwab
2004-05-12 12:03 ` Jakub Jelinek
2004-05-12 12:42 ` Andreas Schwab [this message]
2004-05-17 18:20 ` Ulrich Drepper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jen04dddi9.fsf@sykes.suse.de \
--to=schwab@suse.de \
--cc=jakub@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).