public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: ray@xmission.com To: gcc-gnats@gcc.gnu.org Subject: libgcj/6311: BigInteger Constructor Creates False Results (crypto failures?). Date: Mon, 15 Apr 2002 10:16:00 -0000 [thread overview] Message-ID: <20020415170752.13811.qmail@sources.redhat.com> (raw) >Number: 6311 >Category: libgcj >Synopsis: BigInteger Constructor Creates False Results (crypto failures?). >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Apr 15 10:16:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Ray Whitmer >Release: 3.0.4 >Organization: >Environment: Installing 3.x gcc tools including gcj from the Mandrake 8.2 release installation disk >Description: Java.math.BigInteger has a constructor which accepts a byte array. By getting the byte array, this makes it possible to easily construct a BigInteger which has the same value. In the libgcj implementation, some byte arrays produce the wrong big integer. Attached is a very short test program that demonstrates the problem. If run in a sun java implementation, the BigInteger constructed from the byteArray is correct. But if run against libgcj, the BigInteger constructed from the byte array is 0 instead of the correct value. This could cause Java cryptographic methods to fail. It only fails on certain numbers. I haven't looked at the source to determine the cause of the failure. >How-To-Repeat: This is simple enough and my gcj build is recent enough (and I produced it on prior builds, but didn't know exactly what caused the problem since it was a large functioning program under a Sun JVM. The compilation is very straitforward: gcj --main=BigIntBug -o BigIntBug BigIntBug.java or on the JVM javac BigIntBug.java If I now run BigIntBug, I get: ./BigIntBug The value is 8483895 Byte 0 is 0 Byte 1 is -127 Byte 2 is 116 Byte 3 is 55 After creating from its own internal array, the value is 0 Notice that a 0 is produced. If running under a jvm, I get the following: java -cp . BigIntBug The value is 8483895 Byte 0 is 0 Byte 1 is -127 Byte 2 is 116 Byte 3 is 55 After creating from its own internal array, the value is 8483895 Notice that the correct result is produced. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="BigIntBug.java" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="BigIntBug.java" aW1wb3J0IGphdmEubWF0aC5CaWdJbnRlZ2VyOwogIApwdWJsaWMgY2xhc3MgQmlnSW50QnVnIHsK ICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKQogIHsKICAgIEJpZ0ludGVn ZXIgbnVtYmVyID0gbmV3IEJpZ0ludGVnZXIoIjg0ODM4OTUiKTsKICAgIFN5c3RlbS5vdXQucHJp bnRsbigiVGhlIHZhbHVlIGlzICIgKyBudW1iZXIpOwogICAgYnl0ZVtdIGFycmF5ID0gbnVtYmVy LnRvQnl0ZUFycmF5KCk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IGFycmF5Lmxlbmd0aDsgaSsr KQogICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkJ5dGUgIiArIGkgKyAiIGlzICIgKyBhcnJheVtp XSk7CiAgICBCaWdJbnRlZ2VyIGJ1ZyA9IG5ldyBCaWdJbnRlZ2VyKDEsYXJyYXkpOwogICAgU3lz dGVtLm91dC5wcmludGxuKCJBZnRlciBjcmVhdGluZyBmcm9tIGl0cyBvd24gaW50ZXJuYWwgYXJy YXksIHRoZSB2YWx1ZSBpcyAiICsgYnVnKTsKICB9Cn0K
next reply other threads:[~2002-04-15 17:16 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-15 10:16 ray [this message] 2002-04-15 14:12 tromey
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=20020415170752.13811.qmail@sources.redhat.com \ --to=ray@xmission.com \ --cc=gcc-gnats@gcc.gnu.org \ /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: linkBe 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).