PATCH: oaf segfaults



Hi, 

Attached is a small patch that fixes a bug where unallocated memory was
written into, and a string was accessed after being freed.

/Richard

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/oaf/ChangeLog,v
retrieving revision 1.126.2.61
diff -u -b -B -p -r1.126.2.61 ChangeLog
--- ChangeLog	2001/06/15 01:50:13	1.126.2.61
+++ ChangeLog	2001/07/12 22:55:40
@@ -1,3 +1,9 @@
+2001-07-13  Richard Hult  <rhult codefactory se>
+
+	* liboaf/oaf-registration.c (rloc_file_check): Don't write the
+	string to unallocated memory, and use g_strdup_printf instead of 
+	sprintf. Don't access namecopy after it's freed.
+
 2001-06-14  Peter Williams  <peterw ximian com>
 
 	* configure.in (AC_CHECK_FUNCS): Check for unsetenv.
Index: liboaf/oaf-registration.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-registration.c,v
retrieving revision 1.24.2.4
diff -u -b -B -p -r1.24.2.4 oaf-registration.c
--- liboaf/oaf-registration.c	2001/06/10 23:16:27	1.24.2.4
+++ liboaf/oaf-registration.c	2001/07/12 22:55:42
@@ -480,10 +480,7 @@ rloc_file_check (const OAFBaseServiceReg
                               namecopy,
                               base_service->session_name ? base_service->session_name : "local");
         
-        g_free (namecopy);
-
 	fh = fopen (fn, "r");
-
         g_free (fn);
 
         if (fh == NULL) {
@@ -487,9 +484,15 @@ rloc_file_check (const OAFBaseServiceReg
         g_free (fn);
 
         if (fh == NULL) {
-                sprintf (fn, "/tmp/orbit-%s/reg.%s", uname, namecopy);
+                fn = g_strdup_printf ("/tmp/orbit-%s/reg.%s",
+                                      uname,
+                                      namecopy);
+                
                 fh = fopen (fn, "r");
+                g_free (fn);
         }
+
+        g_free (namecopy);
 
 	if (fh != NULL) {
 		char iorbuf[8192];


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]