[Mimedefang] putc failed: Error 0 line 848 - revisited

Alberto.daSilva at rmb.co.za Alberto.daSilva at rmb.co.za
Wed Dec 11 04:33:00 EST 2002


On Wed, 11 Dec 2002 Jim McCullars wrote:

>I'm running gcc version 3.1 under Solaris 9 and I'm not having
>MIMEDefang problems.  If you have a small code sample (complete - I am not
>a C programmer) that you would like for me to compile and grab the
>assembler output, send it and I'll compile it here.

I'm running:
     Solaris 8 Sparc
     GCC 3.2 (from www.sunfreeware.com)
     MIMEDefang-2.28-BETA-2.
This is related to how "gcc -O2" optimizes putc.

mimedefang.c
line 872:      if (putc(*s, data->fp) == EOF) {

Here is a simple test - create a file with a char(255) & mail it:
$ printf "The 0xff char is seen as EOF, here it is >\377< it breaks putc\n"
> /tmp/sample
$ mailx -v -s "sample" user at md-gateway.com < /tmp/sample

The message tmpfails.
Have a look in the syslog on the MD server for:

Dec 11 10:35:49 radium mimedefang[13250]: [ID 888701 mail.warning] putc
failed: Error 0 line 873

You can also look at the assembler code by using "gcc -g -O2 -s"

The "-g" adds line numbers to mimedefang.s, search for line 872:

        .stabn 68,0,872,.LLM280-body     ; if (putc(*s, data->fp) == EOF) {
        ld      [%l0+24], %o2
        ld      [%o2], %o0
        add     %o0, -1, %o0
        cmp     %o0, 0                   ; buffer full?
        bl      .LL186                  ; call  __flsbuf
        st      %o0, [%o2]
        ld      [%o2+4], %o0
        ldub    [%i1], %o1
        stb     %o1, [%o0]
        add     %o0, 1, %o0
        st      %o0, [%o2+4]
        cmp     %o1, 255                 ; should be cmp   %o1,-1
.LL181:
        be      .LL187                   ; branch equal call syslog if 255
...

If you compile with gcc -O1 (or use Sun Forte 7), the assembler code is
correct.

Regards,

Alberto




More information about the MIMEDefang mailing list