LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File plan-1.10.1-tmp.diff of Package plan (Project home:lnussel:plan)

Index: plan-1.10.1/src/daemon.c
===================================================================
--- plan-1.10.1.orig/src/daemon.c
+++ plan-1.10.1/src/daemon.c
@@ -82,7 +82,7 @@ static void popup_window	(int, struct en
 static void send_mail		(int, struct entry *);
 static void reaper		(int);
 static void exec_program	(struct entry *, char *, BOOL);
-static void write_script	(char *, char *);
+static void write_script	(char *, size_t, char *);
 #ifdef JAPAN
 static int chkctype		(unsigned char, int);
 static unsigned short e2j	(unsigned short);
@@ -488,7 +488,6 @@ static char *get_message(
 	return(NULL);
 }
 
-
 /*
  * execute a program, and pass the entry's message or note text as standard
  * input. The program is executed as a child process, and reads the message
@@ -503,13 +502,13 @@ static char *get_message(
 static void reaper(
 	UNUSED int		sig)
 {
-	char			path[40];	/* script to delete */
+	char			path[4096];	/* script to delete */
 #if (defined BSD && !defined OSF && !defined __FreeBSD__)
 	union wait		dummy;
 #else
 	int			dummy;
 #endif
-	sprintf(path, "/tmp/pland%d", wait(&dummy));
+	snprintf(path, sizeof(path), "/%s/pland%d", getenv("XDG_RUNTIME_DIR"), wait(&dummy));
 	if (debug)
 		printf(_("%s: deleting script \"%s\"\n"), progname, path);
 	(void)unlink(path);
@@ -528,7 +527,7 @@ static void exec_program(
 	char		*q = program;	/* target command line */
 	char		*argv[100];	/* argument vector */
 	int		argc = 0;	/* argument counter */
-	char		scriptname[40];	/* if script, temp file name */
+	char		scriptname[4096];	/* if script, temp file name */
 	int		quote;		/* argument quote flags */
 	char		*msg;		/* msg to print */
 	long		msgsize;	/* strlen(msg) */
@@ -606,7 +605,7 @@ static void exec_program(
 		close(fd[1]);
 		ORPHANIZE;
 		if (script) {
-			write_script(scriptname, program);
+			write_script(scriptname, sizeof(scriptname), program);
 			strcpy(progpath, scriptname);
 			argv[0] = scriptname;
 			argv[1] = 0;
@@ -652,12 +651,13 @@ static void exec_program(
 
 static void write_script(
 	char			*scriptname,	/* script name buffer */
+	size_t			bufsz,		/* length of script buffer */
 	char			*program)	/* script text */
 {
 	int			len;		/* size of program */
 	int			fd;		/* script file */
 
-	sprintf(scriptname, "/tmp/pland%d", getpid());
+	snprintf(scriptname, bufsz, "/%s/pland%d", getenv("XDG_RUNTIME_DIR"), getpid());
 	if (debug)
 		printf(_("%s: generating script \"%s\"\n"), progname,
 								scriptname);