#103 Text parsing failure when sizeof(int) != sizeof(long)

v2.4.2
closed-fixed
5
2008-01-18
2008-01-09
Geoff Adams
No

On NetBSD/alpha (which is LP64), and I believe on any other platform on which long is longer than int, parsing of rfc822 address headers fails. This is because the computation overflows in this libdkim/rfc2822.c line:

#define CMAP_BIT(i) (1 << (unsigned char)(i) % CMAP_NBITS)

The literal 1 is of type int, and CMAP_NBITS is the number of bits in cmap_elem_type, which is unsigned long. So, when you shift the int 1 more than the number of bits in an int, you shift them right out the left side.

The solution is easy; change "1" to "1L" to explicitly make 1 a long to match cmap_elem_type. A patch is attached.

It looks like this bug has been present from at least 0.1.1 all the way through the current 2.4.2.

Discussion

  • Geoff Adams

    Geoff Adams - 2008-01-09
     
  • Anonymous - 2008-01-09
    • assigned_to: nobody --> sm-msk
     
  • Anonymous - 2008-01-09

    Logged In: YES
    user_id=1048957
    Originator: NO

    Makes sense and doesn't break anything on my 32-bit test systems, so it's in for the next release. Thanks for the patch!

     
  • Anonymous - 2008-01-18
    • status: open --> closed-fixed
     
  • Anonymous - 2008-01-18

    Logged In: YES
    user_id=1048957
    Originator: NO

    Patch applied for v2.4.3, now released.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks