--- 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)