RE: converting all newlines to CRLF

From: Vinubalaji Gopal <vgopal_at_abaca.com>
Date: Sat, 6 Apr 2013 00:59:27 +0000

On Fri, 5 Apr 2013, Murray S. Kucherawy wrote:
>The issue with the input message is that some of the lines are
>CRLF-terminated and some are not. This inconsistency is pretty unusual.
>Shouldn't they all be the same? That's certainly what the library
>expects.

>I'm a little wary of changing working code to handle strange input like
>the case you're describing here. Shouldn't the calling application be
>fixed?

I believe I get the message that way, but I can try to do more checks to verify that. Basically we have a program which gets all the email (a lot of spam messages) we receive and writes the message as it receives. I am just using those messages to pass through opendkim using the dkim-chunk api/opendkim-testmsg. If i use the opendkim binary it does the conversion properly and the dkim verification passes. I am interested to know why the following code in dkim_header of libopendkim/dkim.c doesn't handle the case:

 if (*p == '\n' && prev != '\r') /* bare LF */
      {
        dkim_dstring_catn(tmphdr, CRLF, 2);
      }

The patch I created pretty much does the same thing but in dkim_chunk instead of dkim_header. Also I tried to print the whole header (the list) upto the dkim header for the message I posted using the following command (not the most optimistic way to print it, but i just figured it was easier to do it this way when I was in gdb) :

p dkim->dkim_hhead->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_next->hdr_text

And I notice that it does convert the folded headers with bare newlines to folded headers with carriage returns in both the cases (one with the patch and one without the patch). I tried to debug and see how doing it in dkim_chunk make the verification pass and doing the same thing in dkim_header doesn't pass. But it got complicated with the rsa signatures and I couldn't easily debug after that.

Also I would assume that opendkim and opendkim-testmsg should produce the same result for any message in command line (i.e using the dkim_chunk api or the milter api should yield the same result).

--
Vinu
Received on Sat Apr 06 2013 - 01:00:04 PST

This archive was generated by hypermail 2.3.0 : Sat Apr 06 2013 - 01:09:01 PST