Hi,
here are little patches.
== async_start.cpp.diff & switcher.cpp.diff ==
getenv()ed pointers are copied to fixed-size char,
so itoverflows if pointer's lenght > char.
== filesys.cpp.diff ==
Idem, and some trivial simplifications...
== async_file.cpp.diff ==
fread() and fwrite() are size_t, and never return < 0.
== atiopencl.cpp.diff ==
This fopen() is never closed.
Thanks
--- boinc/client/app_start.cpp Sat Oct 6 17:16:08 2012
+++ boinc/client/app_start.cpp Sat Oct 6 17:15:32 2012
@@ -935,7 +935,7 @@
#endif
char* p = getenv("LD_LIBRARY_PATH");
if (p) {
- sprintf(libpath, "%s:%s", newlibs, p);
+ snprintf(libpath, sizeof(libpath), "%s:%s", newlibs, p);
} else {
strcpy(libpath, newlibs);
}
@@ -946,7 +946,7 @@
#ifdef __APPLE__
p = getenv("DYLD_LIBRARY_PATH");
if (p) {
- sprintf(libpath, "%s:%s", newlibs, p);
+ snprintf(libpath, sizeof(libpath), "%s:%s", newlibs, p);
} else {
strcpy(libpath, newlibs);
}
--- boinc/client/async_file.cpp Sat Oct 6 16:00:47 2012
+++ boinc/client/async_file.cpp Sat Oct 6 15:58:17 2012
@@ -90,8 +90,8 @@
unsigned char buf[BUFSIZE];
int retval;
- int n = fread(buf, 1, BUFSIZE, in);
- if (n <= 0) {
+ size_t n = fread(buf, 1, BUFSIZE, in);
+ if (n == 0) {
// copy done. rename temp file
//
fclose(in);
@@ -122,7 +122,7 @@
}
return 1; // tell caller we're done
} else {
- int m = fwrite(buf, 1, n, out);
+ size_t m = fwrite(buf, 1, n, out);
if (m != n) {
error(ERR_FWRITE);
return 1;
--- boinc/lib/filesys.cpp 2012-10-17 13:51:59.866356370 +0200
+++ boinc/lib/filesys.cpp 2012-10-17 13:51:38.054697837 +0200
@@ -291,8 +291,8 @@
return ERR_UNLINK;
}
#else
- int retval = unlink(path);
- if (retval) return ERR_UNLINK;
+ if (unlink(path) == -1)
+ return ERR_UNLINK;
#endif
return 0;
}
@@ -631,8 +631,8 @@
return ERR_RMDIR;
}
#else
- int retval = rmdir(name);
- if (retval) return ERR_RMDIR;
+ if (rmdir(name) == -1)
+ return ERR_RMDIR;
#endif
return 0;
}
@@ -814,7 +814,7 @@
p = getenv("PATH");
if (!p) return ERR_NOT_FOUND;
- strcpy(buf, p);
+ strlcpy(buf, p, sizeof(buf);
p = strtok(buf, ":");
while (p) {
--- boinc/client/switcher.cpp Sat Oct 6 16:50:44 2012
+++ boinc/client/switcher.cpp Sat Oct 6 16:49:30 2012
@@ -104,7 +104,7 @@
#endif
char* p = getenv("LD_LIBRARY_PATH");
if (p) {
- sprintf(libpath, "%s:%s", newlibs, p);
+ snprintf(libpath, sizeof(libpath), "%s:%s", newlibs, p);
} else {
strcpy(libpath, newlibs);
}
@@ -115,7 +115,7 @@
#ifdef __APPLE__
p = getenv("DYLD_LIBRARY_PATH");
if (p) {
- sprintf(libpath, "%s:%s", newlibs, p);
+ snprintf(libpath, sizeof(libpath), "%s:%s", newlibs, p);
} else {
strcpy(libpath, newlibs);
}
--- boinc/samples/atiopencl/atiopencl.cpp 2012-10-17 14:04:23.175870309 +0200
+++ boinc/samples/atiopencl/atiopencl.cpp 2012-10-17 14:03:35.723603284 +0200
@@ -452,6 +452,7 @@
s[i++]=c;
}
s[i]='\0';
+ fclose(infile);
return s;
}
_______________________________________________
boinc_dev mailing list
[email protected]
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.