Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 49034 - crypto++-5.1 fix for amd64
Summary: crypto++-5.1 fix for amd64
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Ryan Phillips (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 45855
  Show dependency tree
 
Reported: 2004-04-26 07:29 UTC by Thomas Weidner
Modified: 2004-06-05 00:43 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
crypto++-5.1-r2.ebuild (crypto++-5.1-r2.ebuild,1.27 KB, text/plain)
2004-04-26 07:29 UTC, Thomas Weidner
Details
crypto++-5.1-amd64.diff (crypto++-5.1-amd64.diff,3.00 KB, patch)
2004-04-26 07:30 UTC, Thomas Weidner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Weidner 2004-04-26 07:29:10 UTC
Hi,

i managed to get cypto++-5.1 working on amd64. a patch and new ebuild, which applies the patch, will be attached. the patch adds some defines to make cypto++ recognize it as 64bit platform (so define types for 32 and 64bit words correctly). and fixes a very interesting bug on amd64. (further reading only if interested).
The file sergent.cpp:439 contains a expression like k[i-1]. k is a pointer to a 32bit unsigned integer and i an unsigned 32bit integer. on 32bit platforms it works like this: i is zero. so i-1 is 0xFFFFFFFF due to an integer underflow. so we have k[0xFFFFFFFF], which is the same as k+0xFFFFFFFF. which is the same as (word32*)((byte*)k+4*0xFFFFFFFF). the multiplication overflows and results in 0xFFFFFFFC. when this value is added to the 32bit pointer k the pointer also overflows resulting in the same as (word32*)((byte*)k-4) which is k[-1],which is what the author of the code wanted. on amd64 pointers are 8bit wide, so adding 0xFFFFFFFC to k does not overflow and produces an invalid pointer. now there are  two solutions. make i a 64bit integer to make k overflow again or use signed integer arithmetic (so i-1 does not underflow). i've choosen the second one for my patch. (i hope this was correct and not too confusing).
Comment 1 Thomas Weidner 2004-04-26 07:29:45 UTC
Created attachment 30085 [details]
crypto++-5.1-r2.ebuild
Comment 2 Thomas Weidner 2004-04-26 07:30:13 UTC
Created attachment 30086 [details, diff]
crypto++-5.1-amd64.diff
Comment 3 Ryan Phillips (RETIRED) gentoo-dev 2004-04-30 10:44:52 UTC
Committed this with the gcc 3.4 fix (#49449).

AMD64 developers: Can you test this please?
Comment 4 Jason Huebel (RETIRED) gentoo-dev 2004-06-04 10:31:37 UTC
Looks good here... All tests passed. I'll unmasked ~amd64. Feel free to close this.
Comment 5 Ryan Phillips (RETIRED) gentoo-dev 2004-06-05 00:43:24 UTC
closed