* Preclude a buffer overflow (though one that cannot occur at present,
given the single caller of this routine). Contributed by Alex
Plotnick.
template on every loop, but only the last several characters.
But I didn't feel like testing the boundary cases in Windows's
_mktemp. */
template on every loop, but only the last several characters.
But I didn't feel like testing the boundary cases in Windows's
_mktemp. */
- strcpy((char*)&buf, template);
- if (MKTEMP((char*)&buf)) {
- if ((fd=open((char*)&buf, O_CREAT|O_EXCL|O_RDWR, mode))!=-1) {
- strcpy(template, (char*)&buf);
+ strncpy(buf, template, PATHNAME_BUFFER_SIZE);
+ buf[PATHNAME_BUFFER_SIZE-1]=0; /* force NULL-termination */
+ if (MKTEMP(buf)) {
+ if ((fd=open(buf, O_CREAT|O_EXCL|O_RDWR, mode))!=-1) {
+ strcpy(template, buf);
return (fd);
} else
if (errno != EEXIST)
return (fd);
} else
if (errno != EEXIST)
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)