Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Aug 2007 17:17:23 +0400 (MSD)
From:      Oleg Sharoiko <os@rsu.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/115969: [patch] anjuta crash due to incorrect patch in ports tree
Message-ID:  <200708311317.l7VDHNik082594@brain.cc.rsu.ru>
Resent-Message-ID: <200708311440.l7VEe1WD028394@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         115969
>Category:       ports
>Synopsis:       [patch] anjuta crash due to incorrect patch in ports tree
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 31 14:40:00 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Oleg Sharoiko
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
Computer Center of Rostov State University
>Environment:
System: FreeBSD brain.cc.rsu.ru 6.2-STABLE FreeBSD 6.2-STABLE #4: Fri Aug 31 11:49:37 MSD 2007 os@brain.cc.rsu.ru:/usr/obj/usr/src/sys/brain.i386.RELENG_6.2007-04-14 i386


	
>Description:
Patch in files/patch-plugins_document-manager_anjuta-docman.c introduces a bug
causing anjuta to crash when opening file over nfs.

Here is the fragment of the code after `make patch' (lines 931 and 932 of
plugins/document-manager/anjuta-docman.c)

        if (normalized_path == NULL)
                (void) strlcpy (normalized_path, uri, PATH_MAX);

This code can not work:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x8062000 (LWP 100243)]
0x292c6d9b in strlcpy () from /lib/libc.so.6
(gdb) bt
#0  0x292c6d9b in strlcpy () from /lib/libc.so.6
#1  0x2b412d7f in anjuta_docman_goto_file_line_mark (docman=0x8654018, 
    fname=0x81c0c40 "file:///usr/home/os/src/tst.cc#11", line=-1, mark=1)
    at anjuta-docman.c:932
#2  0x2b41015f in ifile_open (plugin=0x8482d48, 
    uri=0x81c0c40 "file:///usr/home/os/src/tst.cc#11", e=0x0) at plugin.c:1776

>How-To-Repeat:
	Build/install anjuta.
	Try to open file on nfs (in my case $HOME was on nfs).
>Fix:

	Replace contents of files/patch-plugins_document-manager_anjuta-docman.c
by the following lines:
 
--- plugins/document-manager/anjuta-docman.c.orig	Thu Jun  7 14:56:53 2007
+++ plugins/document-manager/anjuta-docman.c	Fri Aug 31 16:53:19 2007
@@ -902,6 +902,7 @@
 	const gchar *linenum;
 	glong lineno;
 	gboolean is_local_uri;
+	gchar normalized_path_buf[PATH_MAX];
 	gchar *normalized_path = NULL;
 	
 	IAnjutaEditor *te;
@@ -926,9 +927,11 @@
 	/* Get the normalized file path for comparision */
 	is_local_uri = gnome_vfs_uri_is_local (vfs_uri);
 	if (is_local_uri)
-		normalized_path = realpath (gnome_vfs_uri_get_path (vfs_uri), NULL);
-	if (normalized_path == NULL)
-		normalized_path = g_strdup (uri);
+		normalized_path = realpath (gnome_vfs_uri_get_path (vfs_uri), normalized_path_buf);
+	if (normalized_path == NULL) {
+		(void) strlcpy (normalized_path_buf, uri, PATH_MAX);
+		normalized_path = normalized_path_buf;
+	}
 	
 	gnome_vfs_uri_unref (vfs_uri);
 	/* g_free(filename); */
@@ -942,6 +945,7 @@
 		AnjutaDocmanPage *page;
 		gboolean te_is_local_uri;
 		gchar *te_uri;
+		char te_normalized_path_buf[PATH_MAX];
 		gchar *te_normalized_path = NULL;
 		
 		page = (AnjutaDocmanPage *) node->data;
@@ -959,9 +963,11 @@
 		te_is_local_uri = gnome_vfs_uri_is_local (vfs_uri);
 		if (te_is_local_uri)
 			te_normalized_path = realpath (gnome_vfs_uri_get_path (vfs_uri),
-										   NULL);
-		if (te_normalized_path == NULL)
-			te_normalized_path = g_strdup (te_uri);
+										   te_normalized_path_buf);
+		if (te_normalized_path == NULL) {
+			(void) strlcpy (te_normalized_path_buf, te_uri, PATH_MAX);
+			te_normalized_path = te_normalized_path_buf;
+		}
 		gnome_vfs_uri_unref (vfs_uri);
 		
 		if (strcmp (normalized_path, te_normalized_path) == 0)
@@ -982,12 +988,9 @@
 			an_file_history_push (te_uri, lineno);
 			g_free (uri);
 			g_free (te_uri);
-			g_free (normalized_path);
-			g_free (te_normalized_path);
 			return te;
 		}
 		g_free (te_uri);
-		g_free (te_normalized_path);
 		node = g_list_next (node);
 	}
 	te = anjuta_docman_add_editor (docman, uri, NULL);
@@ -1006,7 +1009,6 @@
 		}
 	}
 	g_free (uri);
-	g_free (normalized_path);
 	return te ;
 }
 
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708311317.l7VDHNik082594>