tags 427256 patch
thanks
On Sat, Jun 09, 2007 at 09:18:27PM +0100, Reuben Thomas wrote:
> On Fri, 8 Jun 2007, Robert Millan wrote:
>
> >On Fri, Jun 08, 2007 at 08:35:10PM +0200, Reuben Thomas wrote:
> >>If you single-step in gdb from the call to search_forward you should be
> >>able to see where bogosity sets in. (But don't worry about that too much;
> >>a
> >>correct backtrace is the main thing, I think.)
> >
> >With CVS from just a few minutes ago:
>
> Thanks. Could you carry on until it crashes? BTW, I've tried using qemu,
> but have been unable either to install Debian (although the installer
> boots) or get a live CD to boot.
Oh, silly me! I should have thought that -O2 was scrambling it...
With a clean backtrace I was able to figure out why it failed. In this line:
while (translate[(unsigned)*sp1++] == translate[(unsigned)*sp2++])
(unsigned) doesn't imply unsigned char, so when (signed) *sp1 < 0, you get
a huge number.
I fixed it by replacing this with (unsigned char). My patch also replaces
a similar line in the next function.
--
Robert Millan
My spam trap is [EMAIL PROTECTED] Note: this address is only intended
for spam harvesters. Writing to it will get you added to my black list.
--- src/search.c~ 2007-06-07 00:48:38.000000000 +0200
+++ src/search.c 2007-06-10 22:46:50.000000000 +0200
@@ -92,7 +92,7 @@
for (; s1 <= e1 - s2size; s1++) {
const char *sp1 = s1, *sp2 = s2;
- while (translate[(unsigned)*sp1++] == translate[(unsigned)*sp2++])
+ while (translate[(unsigned char)*sp1++] == translate[(unsigned char)*sp2++])
if (sp2 == e2)
return sp1;
}
@@ -109,7 +109,7 @@
for (; e1 >= s1 + s2size; e1--) {
const char *sp1 = e1, *sp2 = e2;
- while (translate[(unsigned)*--sp1] == translate[(unsigned)*--sp2])
+ while (translate[(unsigned char)*--sp1] == translate[(unsigned char)*--sp2])
if (sp2 == s2)
return sp1;
}