On 28.08.2007 17:29, ron minnich wrote:
On 8/28/07, Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
Can't we do that in an easier way? Idea: struct { char misalign[1]; char magic[8]; } lar_magic __attribute__ ((aligned(16))) = { 0, "LARCHIVE" };
That should guarantee the string to be always misaligned.
My personal preference is not to depend on this type of magic. The fix I posted is really impossible to fail, and we want to guarantee no failure in this important case.
If somewhere in a lar file the magic appears with correct alignment (maybe due to a payload we don't control), your fix will fail as well. However, my fix is not better in that case.
Stefan's comment about not doing stupid brute force is a good point. I am at fault for putting that in, but I did that because in the early days there were bugs in linuxbios LAR parsing code ... we need to take out the brute force.
Yes, that would solve all problems.
Regards, Carl-Daniel