sprintf (tmpl, "%*s/%*sXXXXXX", dlen, dir, plen, pfx);
sprintf (tmpl, "%.*s/%.*sXXXXXX", dlen, dir, plen, pfx);
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,	       int try_tmpdir){  const char *d;  size_t dlen, plen;  if (!pfx || !pfx[0])    {      pfx = "file";      plen = 4;    }  else    {      plen = strlen (pfx);      if (plen > 5)	plen = 5;    }  if (try_tmpdir)    {      d = __secure_getenv ("TMPDIR");      if (d != NULL && direxists (d))	dir = d;      else if (dir != NULL && direxists (dir))	/* nothing */ ;      else	dir = NULL;    }  if (dir == NULL)    {      if (direxists (P_tmpdir))	dir = P_tmpdir;      else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))	dir = "/tmp";      else	{	  __set_errno (ENOENT);	  return -1;	}    }  dlen = strlen (dir);  while (dlen > 1 && dir[dlen - 1] == '/')    dlen--;			/* remove trailing slashes */  /* check we have room for "${dir}/${pfx}XXXXXX\0" */  if (tmpl_len < dlen + 1 + plen + 6 + 1)    {      __set_errno (EINVAL);      return -1;    }  sprintf (tmpl, "%*s/%*sXXXXXX", dlen, dir, plen, pfx);  return 0;}