Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 264575
Collapse All | Expand All

(-)xfig.3.2.5/f_readeps.c (-7 / +20 lines)
Lines 250-260 bitmap_from_gs(file, filetype, pic, urx, Link Here
250
    int         urx, llx, ury, lly;
250
    int         urx, llx, ury, lly;
251
    int         pdf_flag;
251
    int         pdf_flag;
252
{
252
{
253
    static	tempseq = 0;
254
    char        buf[300];
253
    char        buf[300];
255
    FILE       *tmpfp, *pixfile, *gsfile;
254
    FILE       *tmpfp, *pixfile, *gsfile;
256
    char       *psnam, *driver;
255
    char       *psnam, *driver;
257
    int         status, wid, ht, nbitmap;
256
    int         status, wid, ht, nbitmap, fd;
258
    char        tmpfile[PATH_MAX],
257
    char        tmpfile[PATH_MAX],
259
		pixnam[PATH_MAX],
258
		pixnam[PATH_MAX],
260
		errnam[PATH_MAX],
259
		errnam[PATH_MAX],
Lines 270-277 bitmap_from_gs(file, filetype, pic, urx, Link Here
270
	/* re-open the pipe */
269
	/* re-open the pipe */
271
	close_picfile(file, filetype);
270
	close_picfile(file, filetype);
272
	file = open_picfile(tmpfile, &filetype, PIPEOK, pixnam);
271
	file = open_picfile(tmpfile, &filetype, PIPEOK, pixnam);
273
	sprintf(tmpfile, "%s/%s%06d", TMPDIR, "xfig-eps", getpid());
272
   snprintf(tmpfile, sizeof(tmpfile), "%s/xfig-eps.XXXXXX", TMPDIR);
274
	if ((tmpfp = fopen(tmpfile, "wb")) == NULL) {
273
   if ((fd = mkstemp(tmpfile)) == -1 || (tmpfp = fdopen(fd, "wb")) == NULL) {
274
       if (fd != -1) {
275
         unlink(tmpfile);
276
         close(fd);
277
       }
275
	    file_msg("Couldn't open tmp file %s, %s", tmpfile, strerror(errno));
278
	    file_msg("Couldn't open tmp file %s, %s", tmpfile, strerror(errno));
276
	    return False;
279
	    return False;
277
	}
280
	}
Lines 280-289 bitmap_from_gs(file, filetype, pic, urx, Link Here
280
	fclose(tmpfp);
283
	fclose(tmpfp);
281
    }
284
    }
282
    /* make name /TMPDIR/xfig-pic######.pix */
285
    /* make name /TMPDIR/xfig-pic######.pix */
283
    sprintf(pixnam, "%s/%s%06d.pix", TMPDIR, "xfig-pic", tempseq);
286
    snprintf(pixnam, sizeof(pixnam), "%s/xfig-pic.XXXXXX", TMPDIR);
287
    if ((fd = mkstemp(pixnam)) == -1) {
288
        file_msg("Couldn't open tmp file %s, %s", pixnam, strerror(errno));
289
        return False;
290
    }
291
    close(fd);
292
284
    /* and file name for any error messages from gs */
293
    /* and file name for any error messages from gs */
285
    sprintf(errnam, "%s/%s%06d.err", TMPDIR, "xfig-pic", tempseq);
294
    snprintf(errnam, sizeof(errnam), "%s/xfig-picerr.XXXXXX", TMPDIR);
286
    tempseq++;
295
    if ((fd = mkstemp(errnam)) == -1) {
296
       file_msg("Couldn't open tmp file %s, %s", errnam, strerror(errno));
297
       return False;
298
    }
299
    close(fd);
287
300
288
    /* generate gs command line */
301
    /* generate gs command line */
289
    /* for monochrome, use pbm */
302
    /* for monochrome, use pbm */
(-)xfig.3.2.5/f_readgif.c (-2 / +8 lines)
Lines 76-82 read_gif(FILE *file, int filetype, F_pic Link Here
76
	char		buf[BUFLEN],pcxname[PATH_MAX];
76
	char		buf[BUFLEN],pcxname[PATH_MAX];
77
	FILE		*giftopcx;
77
	FILE		*giftopcx;
78
	struct Cmap 	localColorMap[MAX_COLORMAP_SIZE];
78
	struct Cmap 	localColorMap[MAX_COLORMAP_SIZE];
79
	int		i, stat, size;
79
	int		i, stat, size, fd;
80
	int		useGlobalColormap;
80
	int		useGlobalColormap;
81
	unsigned int	bitPixel, red, green, blue;
81
	unsigned int	bitPixel, red, green, blue;
82
	unsigned char	c;
82
	unsigned char	c;
Lines 173-179 read_gif(FILE *file, int filetype, F_pic Link Here
173
	/* now call giftopnm and ppmtopcx */
173
	/* now call giftopnm and ppmtopcx */
174
174
175
	/* make name for temp output file */
175
	/* make name for temp output file */
176
	sprintf(pcxname, "%s/%s%06d.pix", TMPDIR, "xfig-pcx", getpid());
176
	snprintf(pcxname, sizeof(pcxname), "%s/xfig-pcx.XXXXXX", TMPDIR);
177
	if ((fd = mkstemp(pcxname)) == -1) {
178
		file_msg("Cannot create temporary file\n");
179
		return FileInvalid;
180
	}
181
	close(fd);
182
177
	/* make command to convert gif to pcx into temp file */
183
	/* make command to convert gif to pcx into temp file */
178
	sprintf(buf, "giftopnm | ppmtopcx > %s 2> /dev/null", pcxname);
184
	sprintf(buf, "giftopnm | ppmtopcx > %s 2> /dev/null", pcxname);
179
	if ((giftopcx = popen(buf,"w" )) == 0) {
185
	if ((giftopcx = popen(buf,"w" )) == 0) {
(-)xfig.3.2.5/f_readppm.c (-2 / +8 lines)
Lines 34-43 read_ppm(FILE *file, int filetype, F_pic Link Here
34
{
34
{
35
	char	 buf[BUFLEN],pcxname[PATH_MAX];
35
	char	 buf[BUFLEN],pcxname[PATH_MAX];
36
	FILE	*giftopcx;
36
	FILE	*giftopcx;
37
	int	 stat, size;
37
	int	 stat, size, fd;
38
38
39
	/* make name for temp output file */
39
	/* make name for temp output file */
40
	sprintf(pcxname, "%s/%s%06d.pix", TMPDIR, "xfig-pcx", getpid());
40
	snprintf(pcxname, sizeof(pcxname), "%s/xfig-pcx.XXXXXX", TMPDIR);
41
	if ((fd = mkstemp(pcxname)) == -1) {
42
	    file_msg("Cannot open temp file %s: %s\n", pcxname, strerror(errno));
43
	    return FileInvalid;
44
	}
45
	close(fd);
46
41
	/* make command to convert gif to pcx into temp file */
47
	/* make command to convert gif to pcx into temp file */
42
	sprintf(buf, "ppmtopcx > %s 2> /dev/null", pcxname);
48
	sprintf(buf, "ppmtopcx > %s 2> /dev/null", pcxname);
43
	if ((giftopcx = popen(buf,"w" )) == 0) {
49
	if ((giftopcx = popen(buf,"w" )) == 0) {
(-)xfig.3.2.5/f_readtif.c (-3 / +8 lines)
Lines 33-43 read_tif(char *filename, int filetype, F Link Here
33
{
33
{
34
	char	 buf[2*PATH_MAX+40],pcxname[PATH_MAX];
34
	char	 buf[2*PATH_MAX+40],pcxname[PATH_MAX];
35
	FILE	*tiftopcx;
35
	FILE	*tiftopcx;
36
	int	 stat;
36
	int	 stat, fd;
37
37
38
	/* make name for temp output file */
38
	/* make name for temp output file */
39
	sprintf(pcxname, "%s/%s%06d.pix", TMPDIR, "xfig-pcx", getpid());
39
	snprintf(pcxname, sizeof(pcxname), "%s/xfig-pcx.XXXXXX", TMPDIR);
40
40
	if ((fd = mkstemp(pcxname)) == -1) {
41
	    file_msg("Cannot open temp file %s: %s\n", pcxname, strerror(errno));
42
		return FileInvalid;
43
	}
44
	close(fd);
45
	
41
	/* make command to convert tif to pnm then to pcx into temp file */
46
	/* make command to convert tif to pnm then to pcx into temp file */
42
	/* for some reason, tifftopnm requires a file and can't work in a pipe */
47
	/* for some reason, tifftopnm requires a file and can't work in a pipe */
43
	sprintf(buf, "tifftopnm %s 2> /dev/null | ppmtopcx > %s 2> /dev/null",
48
	sprintf(buf, "tifftopnm %s 2> /dev/null | ppmtopcx > %s 2> /dev/null",
(-)xfig.3.2.5/f_util.c (-5 / +11 lines)
Lines 906-919 void update_xfigrc(char *name, char *str Link Here
906
int strain_out(char *name)
906
int strain_out(char *name)
907
{
907
{
908
    char    line[RC_BUFSIZ+1], *tok;
908
    char    line[RC_BUFSIZ+1], *tok;
909
    int fd;
909
910
910
    /* make a temp filename in the user's home directory so we
911
    /* make a temp filename in the user's home directory so we
911
       can just rename it to .xfigrc after creating it */
912
       can just rename it to .xfigrc after creating it */
912
    sprintf(tmpname, "%s/%s%06d", userhome, "xfig-xfigrc", getpid());
913
    snprintf(tmpname, sizeof(tmpname), "%s/xfig-xfigrc.XXXXXX", userhome);
913
    tmpf = fopen(tmpname,"wb");
914
914
    if (tmpf == 0) {
915
    if ((fd = mkstemp(tmpname)) == -1 || (tmpf = fdopen(fd, "wb")) == NULL) {
915
	file_msg("Can't make temporary file for .xfigrc - error: %s",strerror(errno));
916
       file_msg("Can't make temporary file for .xfigrc - error: %s",
916
	return -1;	
917
              strerror(errno));
918
       if (fd != -1) {
919
          unlink(tmpname);
920
          close(fd);
921
       }
922
       return -1;
917
    }
923
    }
918
    /* read the .xfigrc file and write all to temp file except file names */
924
    /* read the .xfigrc file and write all to temp file except file names */
919
    xfigrc = fopen(xfigrc_name,"r");
925
    xfigrc = fopen(xfigrc_name,"r");
(-)xfig.3.2.5/main.c (-3 / +12 lines)
Lines 653-660 void main(int argc, char **argv) Link Here
653
    update_figs = False;
653
    update_figs = False;
654
654
655
    /* get the TMPDIR environment variable for temporary files */
655
    /* get the TMPDIR environment variable for temporary files */
656
    if ((TMPDIR = getenv("XFIGTMPDIR"))==NULL)
656
    if ((TMPDIR = getenv("XFIGTMPDIR"))==NULL) {
657
	TMPDIR = "/tmp";
657
		if ((TMPDIR = getenv("TMPDIR")) == NULL)
658
			TMPDIR = "/tmp";
659
	}
658
660
659
    /* first check args to see if user wants to scale the figure as it is
661
    /* first check args to see if user wants to scale the figure as it is
660
	read in and make sure it is a resonable (positive) number */
662
	read in and make sure it is a resonable (positive) number */
Lines 1669-1675 make_cut_buf_name(void) Link Here
1669
    if (userhome != NULL && *strcpy(cut_buf_name, userhome) != '\0') {
1671
    if (userhome != NULL && *strcpy(cut_buf_name, userhome) != '\0') {
1670
	strcat(cut_buf_name, "/.xfig");
1672
	strcat(cut_buf_name, "/.xfig");
1671
    } else {
1673
    } else {
1672
	sprintf(cut_buf_name, "%s/xfig%06d", TMPDIR, getpid());
1674
		int fd;
1675
		sprintf(cut_buf_name, "%s/xfig.XXXXXX", TMPDIR);
1676
		if ((fd = mkstemp(cut_buf_name)) == -1) {
1677
			fprintf(stderr, "Can't create temporary file for cut_buff: %s\n",
1678
					strerror(errno));
1679
			exit(0);
1680
		}
1681
		close(fd);
1673
    }
1682
    }
1674
}
1683
}
1675
1684
(-)xfig.3.2.5/mode.c (-1 / +1 lines)
Lines 86-92 int min_num_points; Link Here
86
86
87
int		cur_exp_lang;		/* gets initialized in main.c */
87
int		cur_exp_lang;		/* gets initialized in main.c */
88
Boolean		batch_exists = False;
88
Boolean		batch_exists = False;
89
char		batch_file[32];
89
char		batch_file[PATH_MAX];
90
90
91
/*******************************************************************/
91
/*******************************************************************/
92
/* If you change the order of the lang_items[] you must change the */
92
/* If you change the order of the lang_items[] you must change the */
(-)xfig.3.2.5/u_print.c (-3 / +16 lines)
Lines 92-100 void print_to_printer(char *printer, cha Link Here
92
    char	    syspr[2*PATH_MAX+200];
92
    char	    syspr[2*PATH_MAX+200];
93
    char	    tmpfile[PATH_MAX];
93
    char	    tmpfile[PATH_MAX];
94
    char	   *name;
94
    char	   *name;
95
    int     fd;
95
96
96
    sprintf(tmpfile, "%s/%s%06d", TMPDIR, "xfig-print", getpid());
97
    snprintf(tmpfile, sizeof(tmpfile), "%s/xfig-print.XXXXXX", TMPDIR);
97
    warnexist = False;
98
    warnexist = False;
99
    if ((fd = mkstemp(tmpfile)) == -1) {
100
       file_msg("Can't open temp file %s: %s\n", tmpfile, strerror(errno));
101
       return;
102
    }
103
    close(fd);
104
98
    init_write_tmpfile();
105
    init_write_tmpfile();
99
    if (write_file(tmpfile, False)) {
106
    if (write_file(tmpfile, False)) {
100
      end_write_tmpfile();
107
      end_write_tmpfile();
Lines 648-657 exec_prcmd(char *command, char *msg) Link Here
648
    char   errfname[PATH_MAX];
655
    char   errfname[PATH_MAX];
649
    FILE  *errfile;
656
    FILE  *errfile;
650
    char   str[400];
657
    char   str[400];
651
    int	   status;
658
    int	   status, fd;
652
659
653
    /* make temp filename for any errors */
660
    /* make temp filename for any errors */
654
    sprintf(errfname, "%s/xfig-export%06d.err", TMPDIR, getpid());
661
    snprintf(errfname, sizeof(errfname), "%s/xfig-export.XXXXXX", TMPDIR);
662
    if ((fd = mkstemp(errfname)) == -1) {
663
	file_msg("Can't open temp file %s: %s\n", errfname, strerror(errno));
664
	return 1;
665
    }
666
    close(fd);
667
    
655
    /* direct any output from fig2dev to this file */
668
    /* direct any output from fig2dev to this file */
656
    strcat(command, " 2> "); 
669
    strcat(command, " 2> "); 
657
    strcat(command, errfname); 
670
    strcat(command, errfname); 
(-)xfig.3.2.5/w_print.c (-5 / +21 lines)
Lines 294-302 void Link Here
294
do_print_batch(Widget w)
294
do_print_batch(Widget w)
295
{
295
{
296
	FILE	   *infp,*outfp;
296
	FILE	   *infp,*outfp;
297
	char	    tmp_exp_file[32];
297
	char	    tmp_exp_file[PATH_MAX];
298
	char	    str[255];
298
	char	    str[255];
299
	char	    backgrnd[10], grid[80];
299
	char	    backgrnd[10], grid[80];
300
   int       fd;
300
301
301
	if (writing_batch || emptyfigure_msg(print_msg))
302
	if (writing_batch || emptyfigure_msg(print_msg))
302
		return;
303
		return;
Lines 305-315 do_print_batch(Widget w) Link Here
305
	/* this could happen if the user presses the button too fast */
306
	/* this could happen if the user presses the button too fast */
306
	writing_batch = True;
307
	writing_batch = True;
307
308
308
	/* make a temporary name to write the batch stuff to */
309
	sprintf(batch_file, "%s/%s%06d", TMPDIR, "xfig-batch", getpid());
310
	/* make a temporary name to write this figure to */
309
	/* make a temporary name to write this figure to */
311
	sprintf(tmp_exp_file, "%s/%s%06d", TMPDIR, "xfig-exp", getpid());
310
	snprintf(tmp_exp_file, sizeof(tmp_exp_file), "%s/xfig-exp.XXXXXX",
312
	batch_exists = True;
311
		TMPDIR);
312
313
	if (batch_exists != True) {
314
		/* make a temporary name to write the batch stuff to */
315
		sprintf(batch_file, "%s/xfig-batch.XXXXXX", TMPDIR);
316
		if ((fd = mkstemp(batch_file)) == -1) {
317
			file_msg("Error creating temporary file");
318
			return;
319
		}
320
		close(fd);
321
		batch_exists = True;
322
	}
313
	if (!print_popup) 
323
	if (!print_popup) 
314
		create_print_panel(w);
324
		create_print_panel(w);
315
325
Lines 322-327 do_print_batch(Widget w) Link Here
322
	/* make a #rrggbb string from the background color */
332
	/* make a #rrggbb string from the background color */
323
	make_rgb_string(export_background_color, backgrnd);
333
	make_rgb_string(export_background_color, backgrnd);
324
334
335
	if ((fd = mkstemp(tmp_exp_file)) == -1) {
336
		file_msg("Error creating temporary file");
337
		return;
338
	}
339
	close(fd);
340
325
	/* get grid params and assemble into fig2dev parm */
341
	/* get grid params and assemble into fig2dev parm */
326
	get_grid_spec(grid, print_grid_minor_text, print_grid_major_text);
342
	get_grid_spec(grid, print_grid_minor_text, print_grid_major_text);
327
343
(-)xfig.3.2.5/w_srchrepl.c (-4 / +7 lines)
Lines 788-794 spell_check(void) Link Here
788
  char	 *cmd;
788
  char	 *cmd;
789
  char	  str[300];
789
  char	  str[300];
790
  FILE	 *fp;
790
  FILE	 *fp;
791
  int	  len, i;
791
  int	  len, i, fd;
792
  Boolean done = FALSE;
792
  Boolean done = FALSE;
793
  static int lines = 0;
793
  static int lines = 0;
794
794
Lines 804-812 spell_check(void) Link Here
804
  }
804
  }
805
  lines = 0;
805
  lines = 0;
806
806
807
  sprintf(filename, "%s/xfig-spell.%d", TMPDIR, (int)getpid());
807
  snprintf(filename, sizeof(filename), "%s/xfig-spell.XXXXXX", TMPDIR);
808
  fp = fopen(filename, "w");
808
  if ((fd = mkstemp(filename)) == -1 || (fp = fdopen(fd, "w")) == NULL) {
809
  if (fp == NULL) {
809
    if (fd != -1) {
810
	unlink(filename);
811
	close(fd);
812
    }
810
    file_msg("Can't open temporary file: %s: %s\n", filename, strerror(errno));
813
    file_msg("Can't open temporary file: %s: %s\n", filename, strerror(errno));
811
  } else {
814
  } else {
812
    /* locate all text objects and write them to file fp */
815
    /* locate all text objects and write them to file fp */

Return to bug 264575