diff --git a/api/mfile.C b/api/mfile.C
index 5eda10a3e9..cab35c78ff 100644
--- a/api/mfile.C
+++ b/api/mfile.C
@@ -46,6 +46,7 @@ int MFILE::printf(const char* format, ...) {
va_end(ap);
n = strlen(buf2);
buf = (char*)realloc(buf, len+n);
+ if(!buf) return -1;
strncpy(buf+len, buf2, n);
len += n;
return k;
@@ -53,6 +54,7 @@ int MFILE::printf(const char* format, ...) {
size_t MFILE::write(const void *ptr, size_t size, size_t nitems) {
buf = (char *)realloc( buf, len+(size*nitems) );
+ if(!buf) return -1;
memcpy( buf+len, ptr, size*nitems );
len += size*nitems;
return nitems;
@@ -60,6 +62,7 @@ size_t MFILE::write(const void *ptr, size_t size, size_t nitems) {
int MFILE::_putchar(char c) {
buf = (char*)realloc(buf, len+1);
+ if(!buf) return EOF;
buf[len] = c;
len++;
return c;
@@ -68,9 +71,10 @@ int MFILE::_putchar(char c) {
int MFILE::puts(const char* p) {
int n = strlen(p);
buf = (char*)realloc(buf, len+n);
+ if(!buf) return EOF;
strncpy(buf+len, p, n);
len += n;
- return 0;
+ return n;
}
int MFILE::close() {
diff --git a/checkin_notes b/checkin_notes
index 6ceee69fa4..4e5e273b56 100755
--- a/checkin_notes
+++ b/checkin_notes
@@ -8774,6 +8774,24 @@ Gary 25 Dec 2003
- BOINC release 2.16 for windows, Linux, solaris, mac os x 10.3
(os x 10.2 compatability will come soon)
+Jeff 30 Dec 2003
+ - Check for buffer reallocation errors in MFILE functions and return values
+ that mimic the normal system versions of these functions.
+
+ Functions that were changed: * indicates a change.
+ function successful return failure return
+ -------------- ------------------ --------------
+ MFILE::printf() num bytes output -1 *
+ MFILE::write() num bytes output -1 *
+ MFILE::putchar(c) c EOF *
+ MFILE::puts(s) strlen(s) * EOF *
+
+ MFILE::puts() used to return 0 on success. I greped both astropulse
+ and seti_boinc code and found no current use of this function.
+
+ api/
+ mfile.C
+
David 30 Dec 2003
- added optional 1 flag to daemons and tasks
in config.xml. (would prefer "", but couldn't