- 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);