Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002271 [Quercus] minor always 12-21-07 07:25 02-05-08 12:39
Reporter jang View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 3.1.3
Summary 0002271: thinko in base_convert: doesn't always work for large bases
Description There's a bug in MathModule#base_convert - two, actually. The first is the conversion of the input value to a long result:

     if ('0' <= ch && ch <= '9')
        value = ch - '0';
      else if ('a' <= ch && ch <= 'z')
        value = ch - 'a' + 10;
      else if ('A' <= ch && ch <= 'Z')
        value = ch - 'a' + 10;

Pretty sure that last line should be, er,

        value = ch - 'A' + 26;

(which 'a' - 10 doesn't evaluate to).

On output, something similar:

      if (d < 10)
        sb.append((char) (d + '0'));
      else
        sb.append((char) (d - 10 + 'a'));

is also erroneous. Additional information is a sample piece of code that demonstrates this: it'll spew out nonprintable characters occasionally.

Caught this whilst hacking on Elgg to make it run under quercus; as it is, the piece of Elgg code that does this is pretty broken too :-/ but figured you'd probably want the fix anyway.

Cheers,
jan
Additional Information <?php
        $s = md5(time() . "123");
        echo $s;
        echo "\n";
        echo base_convert($s, 16, 36);
?>
Attached Files

- Relationships

- Notes
(0002721)
nam
02-05-08 12:39

php/1328
php/1329
 

- Issue History
Date Modified Username Field Change
12-21-07 07:25 jang New Issue
12-28-07 09:23 jang Issue Monitored: jang
02-05-08 11:38 nam Status new => assigned
02-05-08 11:38 nam Assigned To  => nam
02-05-08 12:39 nam Status assigned => closed
02-05-08 12:39 nam Note Added: 0002721
02-05-08 12:39 nam Resolution open => fixed
02-05-08 12:39 nam Fixed in Version  => 3.1.5


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
30 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker