Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > media > main-src > by-pkgid > f67851bbb65bc42621d212d63246b6ee > files > 1

chbg-1.5-11mdk.src.rpm

--- chbg-1.5.orig/src/config.c
+++ chbg-1.5/src/config.c
@@ -140,12 +140,14 @@
 char *inpath;
 {
 	char *p, *path = NULL;
-	char res[2048];
+	char *res;
+	size_t res_allocated = PATH_MAX;
 	int l;
 
+	res = g_malloc (res_allocated);
 	if (inpath[0] != '/')
 	{
-		if (!getcwd(res, sizeof(res)))
+              if (!getcwd(res, res_allocated))
 			strcpy(res, "/");
 		
 		path = g_strconcat(res, "/" , inpath, NULL);
@@ -171,6 +173,11 @@
 			}
 			else
 			{
+			        size_t  needed_len = strlen(res) + 1 + strlen(p) + 1;
+ 			        if (needed_len > res_allocated) {
+				         res_allocated = needed_len;
+					 res = g_realloc (res, res_allocated);
+				}
 				strcat(res, "/");
 				strncat(res, p, l);
 			}
@@ -182,7 +189,10 @@
 
 	if (path)
 		g_free(path);
-	return g_strdup(res);	
+
+	p = g_strdup(res);
+	g_free (res);
+	return p;
 }
 
 int makealldirs(path)