[Gnucash-changes] r13333 - gnucash/trunk - Compile cleanly with when _FORTIFY_SOURCE is defined. This definition

David Hampton hampton at cvs.gnucash.org
Mon Feb 20 17:00:39 EST 2006


Author: hampton
Date: 2006-02-20 17:00:38 -0500 (Mon, 20 Feb 2006)
New Revision: 13333
Trac: http://svn.gnucash.org/trac/changeset/13333

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/configure.in
   gnucash/trunk/lib/libgsf-1.12.3/gsf/gsf-output-stdio.c
   gnucash/trunk/lib/libgsf-1.12.3/gsf/gsf-utils.c
   gnucash/trunk/src/backend/file/sixtp-utils.c
   gnucash/trunk/src/backend/postgres/test/test-db.c
   gnucash/trunk/src/calculation/fin.c
   gnucash/trunk/src/gnome-utils/gnc-html-graph-gog.c
   gnucash/trunk/src/gnome-utils/gnc-html.c
   gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
Log:
Compile cleanly with when _FORTIFY_SOURCE is defined.  This definition
is forced when building RPMs on FC4.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/ChangeLog	2006-02-20 22:00:38 UTC (rev 13333)
@@ -1,3 +1,16 @@
+2006-02-20  David Hampton  <hampton at employees.org>
+
+	* src/backend/file/sixtp-utils.c:
+	* src/backend/postgres/test/test-db.c:
+	* src/report/report-gnome/gnc-plugin-page-report.c:
+	* src/calculation/fin.c:
+	* src/gnome-utils/gnc-html.c:
+	* src/gnome-utils/gnc-html-graph-gog.c:
+	* lib/libgsf-1.12.3/gsf/gsf-output-stdio.c:
+	* lib/libgsf-1.12.3/gsf/gsf-utils.c:
+	* configure.in: Compile cleanly with when _FORTIFY_SOURCE is
+	defined.  This definition is forced when building RPMs on FC4.
+
 2006-02-20  Derek Atkins  <derek at ihtfp.com>
 
 	* configure.in: fix the qof configure test for OSX.

Modified: gnucash/trunk/configure.in
===================================================================
--- gnucash/trunk/configure.in	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/configure.in	2006-02-20 22:00:38 UTC (rev 13333)
@@ -2027,6 +2027,8 @@
      else if test `echo ${GCC_VERSION} | cut -d. -f1` -ge 4; then
 	# This is gcc == 4.x.x
 	warnFLAGS="${warnFLAGS} -Wdeclaration-after-statement -Wno-pointer-sign"
+	# rpmbuild on FC4 forces this flag. Can't hurt to always compile with it.
+	warnFLAGS="${warnFLAGS} -D_FORTIFY_SOURCE=2"
 	fi
      fi
   fi

Modified: gnucash/trunk/lib/libgsf-1.12.3/gsf/gsf-output-stdio.c
===================================================================
--- gnucash/trunk/lib/libgsf-1.12.3/gsf/gsf-output-stdio.c	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/lib/libgsf-1.12.3/gsf/gsf-output-stdio.c	2006-02-20 22:00:38 UTC (rev 13333)
@@ -254,8 +254,10 @@
 			   stdio->st.st_uid,
 			   stdio->st.st_gid)) {
 			/* We cannot set both.  Maybe we can set one.  */
-			chown (stdio->real_filename, -1, stdio->st.st_gid);
-			chown (stdio->real_filename, stdio->st.st_uid, -1);
+			if (!chown (stdio->real_filename, -1, stdio->st.st_gid)) {
+				gint dc; /* Don't care */
+				dc = chown (stdio->real_filename, stdio->st.st_uid, -1);
+			}
 		}
 		chmod_wrapper (stdio->real_filename, stdio->st.st_mode);
 #endif

Modified: gnucash/trunk/lib/libgsf-1.12.3/gsf/gsf-utils.c
===================================================================
--- gnucash/trunk/lib/libgsf-1.12.3/gsf/gsf-utils.c	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/lib/libgsf-1.12.3/gsf/gsf-utils.c	2006-02-20 22:00:38 UTC (rev 13333)
@@ -130,7 +130,7 @@
 gsf_input_dump (GsfInput *input, gboolean dump_as_hex)
 {
 	gsf_off_t offset = 0;
-	size_t size, count;
+	size_t size, count, count2, written;
 	guint8 const *data;
 
 	/* read in small blocks to excercise things */
@@ -143,8 +143,13 @@
 		g_return_if_fail (data != NULL);
 		if (dump_as_hex)
 			gsf_mem_dump_full (data, count, offset);
-		else
-			fwrite (data, 1, count, stdout);
+		else {
+			count2 = count;
+			do {
+				written = fwrite (data, 1, count2, stdout);
+				count2 -= written;
+			} while (count2 > 0);
+		}
 		size -= count;
 		offset += count;
 	}

Modified: gnucash/trunk/src/backend/file/sixtp-utils.c
===================================================================
--- gnucash/trunk/src/backend/file/sixtp-utils.c	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/src/backend/file/sixtp-utils.c	2006-02-20 22:00:38 UTC (rev 13333)
@@ -499,7 +499,10 @@
 
   if (!str || !ts) return FALSE;
 
-  sscanf(str, " %ld%n", &nanosecs, &charcount);
+  /* The '%n' doesn't count as a conversion. */
+  if (1 != sscanf(str, " %ld%n", &nanosecs, &charcount))
+    return FALSE;
+
   while( (*((gchar*)str + charcount)!='\0') &&
 	 isspace(*((unsigned char*)str + charcount)))
     charcount++;

Modified: gnucash/trunk/src/backend/postgres/test/test-db.c
===================================================================
--- gnucash/trunk/src/backend/postgres/test/test-db.c	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/src/backend/postgres/test/test-db.c	2006-02-20 22:00:38 UTC (rev 13333)
@@ -51,13 +51,11 @@
 save_xml_file(QofSession * session, const char *filename_base)
 {
     QofBackendError io_err;
-    char cwd[1024];
-    char *filename;
+    gchar *cwd, *filename;
 
     g_return_if_fail(session && filename_base);
 
-    getcwd(cwd, sizeof(cwd));
-
+    cwd = g_get_current_dir();
     filename = g_strdup_printf("file:/%s/%s", cwd, filename_base);
 
     qof_session_begin(session, filename, FALSE, TRUE);
@@ -74,6 +72,7 @@
     g_return_if_fail(io_err == ERR_BACKEND_NO_ERR);
 
     g_free(filename);
+    g_free(cwd);
 }
 
 static void

Modified: gnucash/trunk/src/calculation/fin.c
===================================================================
--- gnucash/trunk/src/calculation/fin.c	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/src/calculation/fin.c	2006-02-20 22:00:38 UTC (rev 13333)
@@ -1217,7 +1217,7 @@
   if (places >= 0)
   {
     sprintf (buf, "%.*f", (int) places, x);
-    sscanf (buf, "%lf", &r);
+    r = strtod(buf, NULL);
   }
   else
     r = x;

Modified: gnucash/trunk/src/gnome-utils/gnc-html-graph-gog.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-html-graph-gog.c	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/src/gnome-utils/gnc-html-graph-gog.c	2006-02-20 22:00:38 UTC (rev 13333)
@@ -95,8 +95,7 @@
 read_doubles(const char * string, int nvalues)
 {
   int    n;
-  int    choffset=0;
-  int    accum = 0;
+  gchar *next;
   double * retval = g_new0(double, nvalues);
 
   // guile is going to (puts ...) the elements of the double array
@@ -105,9 +104,9 @@
   gnc_push_locale("C");
   {
     for (n=0; n<nvalues; n++) {
-      sscanf(string + accum, "%le%n", &retval[n], &choffset);
-      accum += choffset;
-    }
+      retval[n] = strtod(string, &next);
+      string = next;
+     }
   }
   gnc_pop_locale();
 
@@ -323,7 +322,7 @@
                           && dataStr != NULL
                           && labelsStr != NULL
                           && colorStr != NULL, FALSE );
-    sscanf( datasizeStr, "%d", &datasize );
+    datasize = atoi( datasizeStr );
     data = read_doubles( dataStr, datasize );
     labels = read_strings( labelsStr, datasize );
     colors = read_strings( colorStr, datasize );
@@ -398,7 +397,7 @@
     colColorsStr = g_hash_table_lookup(eb->params, "col_colors");
     stackedStr = NULL;
     stackedStr   = g_hash_table_lookup(eb->params, "stacked");
-    sscanf( stackedStr, "%d", &stackedInt );
+    stackedInt = atoi( stackedStr );
     stacked = (gboolean)stackedInt;
 
 #if 0 // too strong at the moment.
@@ -409,8 +408,8 @@
                           && rowLabelsStr != NULL
                           && colColorsStr != NULL, FALSE );
 #endif // 0
-    sscanf( datarowsStr, "%d", &datarows );
-    sscanf( datacolsStr, "%d", &datacols );
+    datarows = atoi( datarowsStr );
+    datacols = atoi( datacolsStr );
     data = read_doubles( dataStr, datarows*datacols );
     row_labels = read_strings( rowLabelsStr, datarows );
     col_labels = read_strings( colLabelsStr, datacols );
@@ -500,7 +499,7 @@
     char *datasizeStr, *xDataStr, *yDataStr;
 
     datasizeStr = g_hash_table_lookup( eb->params, "datasize" );
-    sscanf( datasizeStr, "%d", &datasize );
+    datasize = atoi( datasizeStr );
 
     xDataStr = g_hash_table_lookup( eb->params, "x_data" );
     xData = read_doubles( xDataStr, datasize );

Modified: gnucash/trunk/src/gnome-utils/gnc-html.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-html.c	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/src/gnome-utils/gnc-html.c	2006-02-20 22:00:38 UTC (rev 13333)
@@ -1278,7 +1278,12 @@
                    gpointer     user_data)
 {
   FILE *fh = (FILE *) user_data;
-  fwrite (data, len, 1, fh);
+  size_t written;
+
+  do {
+    written = fwrite (data, 1, len, fh);
+    len -= written;
+  } while (len > 0);
   return TRUE;
 }
 
@@ -1528,9 +1533,11 @@
     }
     else if(c == '%') {
       ptr++;
-      sscanf(ptr, "%02X", &hexval);
+      if (1 == sscanf(ptr, "%02X", &hexval))
+	decoded = g_string_append_c(decoded, (char)hexval);
+      else
+	decoded = g_string_append_c(decoded, ' ');
       ptr++;
-      decoded = g_string_append_c(decoded, (char)hexval);
     }
     ptr++;
   }

Modified: gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2006-02-20 21:45:11 UTC (rev 13332)
+++ gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2006-02-20 22:00:38 UTC (rev 13333)
@@ -432,14 +432,14 @@
             && location
             && (strlen(location) > 3)
             && !strncmp("id=", location, 3)) {
-                sscanf(location+3, "%d", &report_id);
+	        report_id = atoi(location+3);
                 DEBUG( "parsed id=%d", report_id );
         }
         else if (!safe_strcmp( type, URL_TYPE_OPTIONS)
                  && location
                  && (strlen(location) > 10)
                  && !strncmp("report-id=", location, 10)) {
-                sscanf(location+10, "%d", &report_id);
+                report_id = atoi(location+10);
                 inst_report = gnc_report_find(report_id);
                 if (inst_report != SCM_BOOL_F) {
                         gnc_plugin_page_report_add_edited_report(priv, inst_report);



More information about the gnucash-changes mailing list