[Mimedefang] putc failed: Error 0 line 848
David F. Skoll
dfs at roaringpenguin.com
Wed Nov 13 11:22:02 EST 2002
On Wed, 13 Nov 2002 Alberto.daSilva at rmb.co.za wrote:
> The problem is when *s = 0xff.
> putc returns -1 == EOF
Then Solaris is broken, or gcc 3.2 on Solaris is.
Casting an unsigned char of 0xFF to int should yield 255, not -1.
I've attached a test program. With gcc 2.95.3 on Solaris 8, the
output is:
Ans = 255
Good... ans != EOF
Ans = -1
Good... ans == EOF
So my Solaris box doesn't seem to suffer from this bug.
And here's the test program:
#include <stdio.h>
#include <sys/types.h>
int
main()
{
u_char s = 0xff;
u_char *t = &s;
FILE *nul = fopen("/dev/null", "w");
int ans;
ans = putc(*t, nul);
printf("Ans = %d\n", ans);
if (ans == EOF) {
printf("WHOAH... ans == EOF\n");
} else {
printf("Good... ans != EOF\n");
}
/* This one had better fail */
fclose(nul);
ans = putc(*t, nul);
printf("Ans = %d\n", ans);
if (ans == EOF) {
printf("Good... ans == EOF\n");
} else {
printf("WHOAH... ans != EOF\n");
}
}
Regards,
David.
More information about the MIMEDefang
mailing list