From: Michael Hampton Date: Wed, 1 Jan 2003 08:07:46 +0000 (+0000) Subject: * commands.c: bugfix for reading from FILE pointers; affected quote, print X-Git-Tag: v7.86~6060 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=798366cc3def97a2ea8eb65cceb8a6856b51742c;p=citadel.git * commands.c: bugfix for reading from FILE pointers; affected quote, print and external editor. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 804b20692..653c06ee4 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 601.100 2003/01/01 08:07:46 error + * commands.c: bugfix for reading from FILE pointers; affected quote, print + and external editor. + Revision 601.99 2002/12/28 05:33:29 ajc * ical_dezonify: set is_utc=1 even if we didn't convert from some arbitrary timezone. Presumably this means the time was already UTC, and we really @@ -4342,4 +4346,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/commands.c b/citadel/commands.c index 3899fc942..795a8289f 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -1300,6 +1300,8 @@ int fmout( /* Read the entire message body into memory */ if (fpin) { + size_t got = 0; + fseek(fpin, 0, SEEK_END); i = ftell(fpin); rewind(fpin); @@ -1310,13 +1312,21 @@ int fmout( logoff(NULL, 3); } - g = fread(buffer, i, 1, fpin); - if (g == 1) { + while (got < i) { + size_t g; + + g = fread(buffer + got, 1, i - got, fpin); + got += g; + if (g < i - got) { + /* Interrupted system call, keep going */ + if (errno == EINTR) + continue; + /* At this point we have either EOF or error */ + i = got; + break; + } buffer[i] = 0; } - else { - buffer[0] = 0; - } } else { buffer = text; }