[SCM] BOINC packaging branch, master, updated. debian/7.0.65+dfsg-3-7-gae67803

Steffen Moeller steffen_moeller at gmx.de
Fri May 17 17:28:48 UTC 2013


The following commit has been merged in the master branch:
commit ae6780304db88c4a3d317880d415b729b5ccc295
Author: Steffen Moeller <steffen_moeller at gmx.de>
Date:   Fri May 17 19:28:11 2013 +0200

    Revisiting file pointer leaks.

diff --git a/debian/changelog b/debian/changelog
index 44bee4f..4ef5e63 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,8 @@
-boinc (7.1.1+dfsg-1) UNRELEASED; urgency=low
+boinc (7.1.1+dfsg-1) experimental; urgency=low
 
+  [ Steffen Moeller ]
+  * Introduced series of fclose() to fight potential file pointer leak
+  [ Gianfranco Costamagna ]
   * New upstream release.
   * Tweaked debian/watch.
   * Removed some patches accepted upstream.
diff --git a/debian/patches/fopen_closing.patch b/debian/patches/fopen_closing.patch
new file mode 100644
index 0000000..8e0ffa4
--- /dev/null
+++ b/debian/patches/fopen_closing.patch
@@ -0,0 +1,164 @@
+Index: boinc_debian/lib/crypt_prog.cpp
+===================================================================
+--- boinc_debian.orig/lib/crypt_prog.cpp
++++ boinc_debian/lib/crypt_prog.cpp
+@@ -152,6 +152,8 @@
+         if (!fpub) die("fopen");
+         print_key_hex(fpriv, (KEY*)&private_key, sizeof(private_key));
+         print_key_hex(fpub, (KEY*)&public_key, sizeof(public_key));
++	fclose(fpriv);
++	fclose(fpub);
+ 
+     } else if (!strcmp(argv[1], "-sign")) {
+         if (argc < 4) {
+@@ -166,6 +168,7 @@
+         signature.len = 256;
+         retval = sign_file(argv[2], private_key, signature);
+         print_hex_data(stdout, signature);
++	fclose(fpriv);
+     } else if (!strcmp(argv[1], "-sign_string")) {
+         if (argc < 4) {
+             usage();
+@@ -177,6 +180,7 @@
+         if (retval) die("scan_key_hex\n");
+         generate_signature(argv[2], cbuf, private_key);
+         puts(cbuf);
++	fclose(fpriv);
+     } else if (!strcmp(argv[1], "-verify")) {
+         if (argc < 5) {
+             usage();
+@@ -190,6 +194,8 @@
+         signature.data = signature_buf;
+         signature.len = 256;
+         retval = scan_hex_data(f, signature);
++	fclose(f);
++	fclose(fpub);
+         if (retval) die("scan_hex_data");
+ 
+         char md5_buf[64];
+@@ -219,6 +225,8 @@
+         if (!fpub) die("fopen");
+         retval = scan_key_hex(fpub, (KEY*)&public_key, sizeof(public_key));
+         if (retval) die("read_public_key");
++	fclose(fpriv);
++	fclose(fpub);
+         strcpy((char*)buf2, "encryption test successful");
+         in.data = buf2;
+         in.len = strlen((char*)in.data);
+@@ -236,6 +244,7 @@
+         signature.data = signature_buf;
+         signature.len = 256;
+         retval = scan_hex_data(f, signature);
++	fclose(f);
+         if (retval) die("cannot scan_hex_data");
+         certpath = check_validity(argv[4], argv[2], signature.data, argv[5]);
+         if (certpath == NULL) {
+@@ -391,6 +400,7 @@
+                     die("fopen");
+                 }
+                 print_key_hex(fpub, (KEY*)&public_key, sizeof(public_key));
++		fclose(fpub);
+             }
+         }
+     } else {
+Index: boinc_debian/lib/mfile.cpp
+===================================================================
+--- boinc_debian.orig/lib/mfile.cpp
++++ boinc_debian/lib/mfile.cpp
+@@ -38,13 +38,14 @@
+ MFILE::MFILE() {
+     buf = (char*)malloc(64*1024);
+     len = 0;
++    f = NULL;
+ }
+ 
+ MFILE::~MFILE() {
+-    if (buf) free(buf);
++    close();
+ }
+ 
+-int MFILE::open(const char* path, const char* mode) {
++int MFILE::open(const char* const path, const char* const mode) {
+     f = boinc_fopen(path, mode);
+     if (!f) return ERR_FOPEN;
+     if (!buf) buf = (char*)malloc(64*1024);
+@@ -67,7 +68,7 @@
+ 
+ #define BUFSIZE 100000
+ 
+-int MFILE::vprintf(const char* format, va_list ap) {
++int MFILE::vprintf(const char* const format, va_list ap) {
+     char buf2[BUFSIZE];
+     int n, k;
+ 
+@@ -93,7 +94,7 @@
+     return k;
+ }
+ 
+-int MFILE::printf(const char* format, ...) {
++int MFILE::printf(const char* const format, ...) {
+     int n;
+     va_list ap;
+ 
+@@ -103,7 +104,7 @@
+     return n;
+ }
+ 
+-size_t MFILE::write(const void *ptr, size_t size, size_t nitems) {
++size_t MFILE::write(const void *ptr, const size_t size, const size_t nitems) {
+     buf = (char *)realloc_aux( buf, len+(size*nitems)+1 );
+     if (!buf) {
+         fprintf(stderr,
+@@ -118,7 +119,7 @@
+     return nitems;
+ }
+ 
+-int MFILE::_putchar(char c) {
++int MFILE::_putchar(const char c) {
+     buf = (char*)realloc_aux(buf, len+1+1);
+     if (!buf) {
+         fprintf(stderr,
+@@ -132,7 +133,7 @@
+     return c;
+ }
+ 
+-int MFILE::puts(const char* p) {
++int MFILE::puts(const char* const p) {
+     int n = (int)strlen(p);
+     buf = (char*)realloc_aux(buf, len+n+1);
+     if (!buf) {
+Index: boinc_debian/lib/parse_test.cpp
+===================================================================
+--- boinc_debian.orig/lib/parse_test.cpp
++++ boinc_debian/lib/parse_test.cpp
+@@ -52,6 +52,7 @@
+         exit(1);
+     }
+     parse(f);
++    fclose(f);
+ }
+ 
+ /* try it with something like:
+Index: boinc_debian/lib/mfile.h
+===================================================================
+--- boinc_debian.orig/lib/mfile.h
++++ boinc_debian/lib/mfile.h
+@@ -37,12 +37,12 @@
+ public:
+     MFILE();
+     ~MFILE();
+-    int open(const char* path, const char* mode);
+-    int _putchar(char);
+-    int puts(const char*);
+-    int vprintf(const char* format, va_list);
+-    int printf(const char* format, ...);
+-    size_t write(const void *, size_t size, size_t nitems);
++    int open(const char* const path, const char* const mode);
++    int _putchar(const char);
++    int puts(const char* const s);
++    int vprintf(const char* const format, va_list);
++    int printf(const char* const format, ...);
++    size_t write(const void *, const size_t size, const size_t nitems);
+     int close();
+     int flush();
+     long tell() const;
diff --git a/debian/patches/investigate_boinc_api.patch b/debian/patches/investigate_boinc_api.patch
index af876d5..53e6d59 100644
--- a/debian/patches/investigate_boinc_api.patch
+++ b/debian/patches/investigate_boinc_api.patch
@@ -1,5 +1,7 @@
---- a/api/boinc_api.cpp
-+++ b/api/boinc_api.cpp
+Index: boinc_debian/api/boinc_api.cpp
+===================================================================
+--- boinc_debian.orig/api/boinc_api.cpp
++++ boinc_debian/api/boinc_api.cpp
 @@ -331,7 +331,7 @@
  
      if (standalone) return true;
@@ -43,17 +45,17 @@
      if (other_pid) {
          sprintf(buf, "<other_pid>%d</other_pid>\n", other_pid);
 -        strcat(msg_buf, buf);
-+        strncat(msg_buf, buf, sizeof(msg_buf));
++        strlcat(msg_buf, buf, sizeof(msg_buf));
      }
      if (_bytes_sent) {
          sprintf(buf, "<bytes_sent>%f</bytes_sent>\n", _bytes_sent);
 -        strcat(msg_buf, buf);
-+        strncat(msg_buf, buf, sizeof(msg_buf));
++        strlcat(msg_buf, buf, sizeof(msg_buf));
      }
      if (_bytes_received) {
          sprintf(buf, "<bytes_received>%f</bytes_received>\n", _bytes_received);
 -        strcat(msg_buf, buf);
-+        strncat(msg_buf, buf, sizeof(msg_buf));
++        strlcat(msg_buf, buf, sizeof(msg_buf));
      }
      if (app_client_shm->shm->app_status.send_msg(msg_buf)) {
          return 0;
@@ -70,10 +72,10 @@
      DirScanner dirscan(path);
      while (dirscan.scan(filename)) {
 -        strcpy(buf, filename.c_str());
-+        strncpy(buf, filename.c_str(), sizeof(buf));
++        strlcpy(buf, filename.c_str(), sizeof(buf));
          if (strstr(buf, UPLOAD_FILE_STATUS_PREFIX) != buf) continue;
 -        strcpy(log_name, buf+strlen(UPLOAD_FILE_STATUS_PREFIX));
-+        strncpy(log_name, buf+strlen(UPLOAD_FILE_STATUS_PREFIX), sizeof(log_name));
++        strlcpy(log_name, buf+strlen(UPLOAD_FILE_STATUS_PREFIX), sizeof(log_name));
          FILE* f = boinc_fopen(filename.c_str(), "r");
          if (!f) {
              fprintf(stderr,
@@ -91,7 +93,7 @@
          GetFullPathName(path, MAXPATHLEN, abspath, NULL);
  #else
 -        strcpy(abspath, path);
-+        strncpy(abspath, path, sizeof(abspath));
++        strlcpy(abspath, path, sizeof(abspath));
  #endif
          argv[0] = const_cast<char*>(GRAPHICS_APP_FILENAME);
          if (fullscreen) {
@@ -113,3 +115,12 @@
              "<remote_desktop_addr>%s</remote_desktop_addr>",
              remote_desktop_addr
          );
+@@ -1462,7 +1466,7 @@
+         DirScanner dirscan(path);
+         while (dirscan.scan(filename)) {
+             if (strstr(filename.c_str(), "trickle_down")) {
+-                strncpy(buf, filename.c_str(), len);
++                strlcpy(buf, filename.c_str(), len);
+                 return true;
+             }
+         }
diff --git a/debian/patches/lib_cppcheck.patch b/debian/patches/lib_cppcheck.patch
new file mode 100644
index 0000000..56ac006
--- /dev/null
+++ b/debian/patches/lib_cppcheck.patch
@@ -0,0 +1,18 @@
+Index: boinc_debian/lib/unix_util.cpp
+===================================================================
+--- boinc_debian.orig/lib/unix_util.cpp
++++ boinc_debian/lib/unix_util.cpp
+@@ -61,7 +61,13 @@
+             }
+             if (i!=envstrings.end()) {
+                 // we allocated this string.  Reallocate it.
++		char *b=buf;
+                 buf=(char *)realloc(buf,strlen(name)+strlen(value)+2);
++		if (!buf) {
++		    free(b);
++		    errno=ENOMEM;
++		    return -1;
++		}
+                 *i=buf;
+             } else {
+                 // someone else allocated the string.  Allocate new memory.
diff --git a/debian/patches/series b/debian/patches/series
index ed5c947..d9d0992 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -62,3 +62,5 @@ zip_only_built_with_server.patch
 hurd-ftbfs.patch
 disable_new_version_check.patch
 server_installs_itself.patch
+lib_cppcheck.patch
+fopen_closing.patch

-- 
BOINC packaging



More information about the pkg-boinc-commits mailing list