Browse Source

src/frontend/plotting/plotit.c, plotit(), fix command line buffer overflow

pre-master-46
rlar 12 years ago
parent
commit
45cfdde701
  1. 16
      src/frontend/plotting/plotit.c

16
src/frontend/plotting/plotit.c

@ -234,8 +234,8 @@ plotit(wordlist *wl, char *hcopy, char *devname)
char *xn; char *xn;
int i, j, xt; int i, j, xt;
double tt; double tt;
wordlist *wwl;
char cline[BSIZE_SP], buf[BSIZE_SP], *pname;
wordlist *wwl, *tail;
char *cline = NULL, buf[BSIZE_SP], *pname;
char *nxlabel = NULL, *nylabel = NULL, *ntitle = NULL; char *nxlabel = NULL, *nylabel = NULL, *ntitle = NULL;
double tstep, tstart, tstop, ttime; double tstep, tstart, tstop, ttime;
@ -269,24 +269,27 @@ plotit(wordlist *wl, char *hcopy, char *devname)
nylabel = getword(wwl, "ylabel"); nylabel = getword(wwl, "ylabel");
ntitle = getword(wwl, "title"); ntitle = getword(wwl, "title");
pname = wl_flatten(wwl->wl_next); pname = wl_flatten(wwl->wl_next);
(void) sprintf(cline, "plot %s", pname);
tail = wl_cons(tprintf("plot %s", pname), NULL);
tfree(pname); tfree(pname);
wl_free(wwl); wl_free(wwl);
/* add title, xlabel or ylabel, if available, with quotes '' */ /* add title, xlabel or ylabel, if available, with quotes '' */
if (nxlabel) { if (nxlabel) {
sprintf(cline, "%s xlabel '%s'", cline, nxlabel);
tail = wl_cons(tprintf("xlabel '%s'", nxlabel), tail);
tfree(nxlabel); tfree(nxlabel);
} }
if (nylabel) { if (nylabel) {
sprintf(cline, "%s ylabel '%s'", cline, nylabel);
tail = wl_cons(tprintf("ylabel '%s'", nylabel), tail);
tfree(nylabel); tfree(nylabel);
} }
if (ntitle) { if (ntitle) {
sprintf(cline, "%s title '%s'", cline, ntitle);
tail = wl_cons(tprintf("title '%s'", ntitle), tail);
tfree(ntitle); tfree(ntitle);
} }
cline = wl_flatten(wl_reverse(tail));
wl_free(tail);
/* Now extract all the parameters. */ /* Now extract all the parameters. */
sameflag = getflag(wl, "samep"); sameflag = getflag(wl, "samep");
@ -1030,6 +1033,7 @@ plotit(wordlist *wl, char *hcopy, char *devname)
rtn = TRUE; rtn = TRUE;
quit: quit:
tfree(cline);
free_pnode(names); free_pnode(names);
FREE(title); FREE(title);
quit1: quit1:

Loading…
Cancel
Save