patch-sam_unix_c 653 B

123456789101112131415161718192021222324252627282930313233
  1. $OpenBSD: patch-sam_unix_c,v 1.2 2016/03/17 21:07:32 naddy Exp $
  2. --- sam/unix.c.orig Thu Mar 17 21:21:48 2016
  3. +++ sam/unix.c Thu Mar 17 21:21:48 2016
  4. @@ -147,18 +147,18 @@ notifyf(void *a, char *b) /* never called */
  5. int
  6. newtmp(int i)
  7. {
  8. - char *s;
  9. - FILE *f;
  10. - extern char *tempnam(const char*, const char*);
  11. + char file[40];
  12. + int fd;
  13. + extern int mkstemp(char *);
  14. - s = tempnam(TMPDIR, "sam.");
  15. - if (!s)
  16. + snprintf(file, 40, "%s/sam.XXXXXXXXXX", TMPDIR);
  17. + fd = mkstemp(file);
  18. + if(fd < 0){
  19. + unlink(file);
  20. return -1;
  21. - f = fopen(s, "w+");
  22. - if (!f)
  23. - return -1;
  24. - unlink(s);
  25. - return fileno(f);
  26. + }
  27. + unlink(file);
  28. + return fd;
  29. }
  30. void