On Sun, Nov 02, 2003 at 06:12:24PM +0100, Paul Diaconescu wrote:
> [Sun Nov 02 18:01:37 2003] [error] [client 217.151.192.51] putchar failed -
> aborting!, referer:
> http://ebrev.mine.nu/cgi-bin/sqwebmail/login/pauld.authpam/22F343E9BC2AA7BA0237E1A839CC143E/1067792483?folder=INBOX&form=readmsg&pos=17
Well, there's your error. The following section is being triggered:
if (putchar((int)(unsigned char)*p++) == EOF)
{
fprintf(stderr, "putchar failed - aborting!\n");
cleanup();
fake_exit(0);
}
and the problem is that putchar(255) is returning EOF (-1) instead of 255.
Stupid Solaris. So, this function needs rewriting without using putchar.
Try this new patch (against a clean folder.c) - which is probably more
efficient that the old code anyway. If that is the problem then the code
needs going through to see if there are any more examples of this.
Cheers,
Brian.
--- sqwebmail/folder.c.orig Sun Nov 2 16:02:49 2003
+++ sqwebmail/folder.c Sun Nov 2 21:06:15 2003
@@ -3402,12 +3408,17 @@
static int download_func(const char *p, size_t cnt, void *voidptr)
{
- while (cnt--)
- if (putchar((int)(unsigned char)*p++) == EOF)
+ while (cnt > 0)
+ {
+ size_t res = write(STDOUT_FILENO, p, cnt);
+ if (res <= 0)
{
cleanup();
fake_exit(0);
}
+ p += res;
+ cnt -= res;
+ }
return (0);
}