summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2011-05-04 20:27:43 +0100
committerMichael Meeks <michael.meeks@novell.com>2011-05-04 20:30:21 +0100
commit226362003a4705edd15764e0b022d6a3b351fb82 (patch)
tree78f9bf30d1300718ca0100904537989c370673a0
parentcdfb1d195053f18dbeb8ce8ac750e611463811e3 (diff)
fix fdo#36838 by avoiding -L argument to pagein
-rwxr-xr-xdesktop/source/pagein/pagein.c15
-rw-r--r--desktop/unx/source/args.c8
-rwxr-xr-xdesktop/unx/source/start.c42
3 files changed, 44 insertions, 21 deletions
diff --git a/desktop/source/pagein/pagein.c b/desktop/source/pagein/pagein.c
index 097b093fe3..b625c57c6d 100755
--- a/desktop/source/pagein/pagein.c
+++ b/desktop/source/pagein/pagein.c
@@ -107,16 +107,25 @@ int pagein_execute (int argc, char **argv)
if ((argv[i][0] == '@') && ((fp = fopen (argv[i], "r")) == 0))
{
- char path[1024];
+ char fullpath[4096];
+ char *path;
+ strncpy (fullpath, argv[i] + 1, 3000);
+ if (!(path = strrchr (fullpath, '/')))
+ path = fullpath;
+ else
+ path++;
+
if ((fp = fopen (&(argv[i][1]), "r")) == 0)
{
fprintf (stderr, "fopen %s: %s\n", &(argv[i][1]), strerror(errno));
continue;
}
- while (fgets (path, sizeof(path), fp) != 0)
+ while (fgets (path, 1024, fp) != 0)
{
path[strlen(path) - 1] = '\0', k = 0;
- if (do_pagein (path, &k) == 0)
+
+ /* paths relative to the location of the pagein file */
+ if (do_pagein (fullpath, &k) == 0)
{
/* accumulate total size */
nbytes += k;
diff --git a/desktop/unx/source/args.c b/desktop/unx/source/args.c
index 0f47f791d5..d69fe62e24 100644
--- a/desktop/unx/source/args.c
+++ b/desktop/unx/source/args.c
@@ -61,10 +61,10 @@ static struct {
{ "minimized", 0, 1, 0, 0, NULL },
/* pagein bits */
- { "writer", 0, 0, 0, 0, "@pagein-writer" },
- { "calc", 0, 0, 0, 0, "@pagein-calc" },
- { "draw", 0, 0, 0, 0, "@pagein-draw" },
- { "impress", 0, 0, 0, 0, "@pagein-impress" },
+ { "writer", 0, 0, 0, 0, "pagein-writer" },
+ { "calc", 0, 0, 0, 0, "pagein-calc" },
+ { "draw", 0, 0, 0, 0, "pagein-draw" },
+ { "impress", 0, 0, 0, 0, "pagein-impress" },
/* nothing much */
{ "version", 0, 1, 1, 1, NULL },
diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index b0f5ab393a..b6ae8aa3a0 100755
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -728,6 +728,24 @@ system_checks( void )
/* re-use the pagein code */
extern int pagein_execute (int argc, char **argv);
+#define REL_PATH "/../basis-link/program"
+static char *build_pagein_path (Args *args, const char *pagein_name)
+{
+ char *path;
+ rtl_String *app_path;
+
+ app_path = ustr_to_str (args->pAppPath);
+ path = malloc (app_path->length + strlen (pagein_name) + sizeof (REL_PATH) + 8);
+ strcpy (path, "@");
+ strcpy (path + 1, rtl_string_getStr (app_path));
+ strcat (path, "/../basis-link/program/");
+ strcat (path, pagein_name);
+
+ rtl_string_release( app_path );
+
+ return path;
+}
+
void
exec_pagein (Args *args)
{
@@ -735,24 +753,20 @@ exec_pagein (Args *args)
#ifdef MACOSX
(void)args;
#else
- char *argv[5];
- rtl_String *app_path;
-
- app_path = ustr_to_str (args->pAppPath);
+ char *argv[3];
+ /* don't use -L - since that does a chdir that breaks relative paths */
argv[0] = "dummy-pagein";
- argv[1] = malloc (app_path->length + sizeof ("-L/../basis-link/program") + 2);
- strcpy (argv[1], "-L");
- strcat (argv[1], app_path->buffer);
- strcat (argv[1], "/../basis-link/program");
- argv[2] = "@pagein-common";
- argv[3] = (char *)args->pPageinType;
- argv[4] = NULL;
-
- rtl_string_release( app_path );
+ argv[1] = build_pagein_path (args, "pagein-common");
+ if (args->pPageinType) {
+ argv[2] = build_pagein_path (args, args->pPageinType);
+ } else
+ argv[2] = NULL;
- pagein_execute (args->pPageinType ? 4 : 3, argv);
+ pagein_execute (args->pPageinType ? 3 : 2, argv);
+ if (argv[2])
+ free (argv[2]);
free (argv[1]);
#endif
}