grace-5.1.22-mkstemp.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. diff -Naur grace-5.1.22/src/editpwin.c grace-5.1.22.new/src/editpwin.c
  2. --- grace-5.1.22/src/editpwin.c 2006-06-03 17:19:52.000000000 -0400
  3. +++ grace-5.1.22.new/src/editpwin.c 2008-07-26 12:45:21.000000000 -0400
  4. @@ -776,12 +776,12 @@
  5. */
  6. void do_ext_editor(int gno, int setno)
  7. {
  8. - char *fname, ebuf[256];
  9. + char fname[64], ebuf[256];
  10. FILE *cp;
  11. int save_autos;
  12. - fname = tmpnam(NULL);
  13. - cp = grace_openw(fname);
  14. + strcpy(fname, "grace-XXXXXX");
  15. + cp = fdopen(mkstemp(fname), "wb");
  16. if (cp == NULL) {
  17. return;
  18. }
  19. diff -Naur grace-5.1.22/src/plotone.c grace-5.1.22.new/src/plotone.c
  20. --- grace-5.1.22/src/plotone.c 2005-05-19 16:30:25.000000000 -0400
  21. +++ grace-5.1.22.new/src/plotone.c 2008-07-26 12:45:40.000000000 -0400
  22. @@ -121,19 +121,27 @@
  23. sprintf(print_file, "%s.%s", get_docbname(), dev.fext);
  24. }
  25. strcpy(fname, print_file);
  26. + prstream = grace_openw(fname);
  27. } else {
  28. + int hdfd;
  29. s = get_print_cmd();
  30. if (s == NULL || s[0] == '\0') {
  31. errmsg("No print command defined, output aborted");
  32. return;
  33. }
  34. - tmpnam(fname);
  35. - /* VMS doesn't like extensionless files */
  36. - strcat(fname, ".prn");
  37. + strcpy(fname, "grace-hardcopy-XXXXXX");
  38. + hdfd=mkstemp(fname);
  39. + if (hdfd == -1) {
  40. + errmsg("Could not create a temporary file, output aborted.");
  41. + return;
  42. + }
  43. + prstream = fdopen(hdfd, "wb");
  44. + if (prstream == NULL) {
  45. + errmsg("Could not create a temporary file, output aborted.");
  46. + return;
  47. + }
  48. }
  49. - prstream = grace_openw(fname);
  50. -
  51. if (prstream == NULL) {
  52. return;
  53. }