memcpy ((char *) dirp->dirname, cp, len + 1);
*((char *) __mempcpy ((char *) dirp->dirname, cp, len)) = '\0';
fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,	      int check_trusted, const char *what, const char *where){  char *cp;  size_t nelems = 0;  while ((cp = __strsep (&rpath, sep)) != NULL)    {      struct r_search_path_elem *dirp;      size_t len = strlen (cp);      /* `strsep' can pass an empty string.  This has to be         interpreted as `use the current directory'. */      if (len == 0)	{	  static const char curwd[] = "./";	  cp = (char *) curwd;	}      /* Remove trailing slashes (except for "/").  */      while (len > 1 && cp[len - 1] == '/')	--len;      /* Now add one if there is none so far.  */      if (len > 0 && cp[len - 1] != '/')	cp[len++] = '/';      /* See if this directory is already known.  */      for (dirp = _dl_all_dirs; dirp != NULL; dirp = dirp->next)	if (dirp->dirnamelen == len && memcmp (cp, dirp->dirname, len) == 0)	  break;      if (dirp != NULL)	{	  /* It is available, see whether it's on our own list.  */	  size_t cnt;	  for (cnt = 0; cnt < nelems; ++cnt)	    if (result[cnt] == dirp)	      break;	  if (cnt == nelems)	    result[nelems++] = dirp;	}      else	{	  size_t cnt;	  enum r_dir_status init_val;	  size_t where_len = where ? strlen (where) + 1 : 0;	  /* It's a new directory.  Create an entry and add it.  */	  dirp = (struct r_search_path_elem *)	    malloc (sizeof (*dirp) + ncapstr * sizeof (enum r_dir_status)		    + where_len + len + 1);	  if (dirp == NULL)	    _dl_signal_error (ENOMEM, NULL,			      N_("cannot create cache for search path"));	  dirp->dirname = ((char *) dirp + sizeof (*dirp)			   + ncapstr * sizeof (enum r_dir_status));	  memcpy ((char *) dirp->dirname, cp, len + 1);	  dirp->dirnamelen = len;	  if (len > max_dirnamelen)	    max_dirnamelen = len;	  /* Make sure we don't use untrusted directories if we run SUID.  */	  if (__builtin_expect (check_trusted, 0))	    {	      const char *trun = system_dirs;	      size_t idx;	      /* By default we don't trust anything.  */	      init_val = nonexisting;	      /* All trusted directories must be complete names.  */	      if (cp[0] == '/')		{		  for (idx = 0; idx < nsystem_dirs_len; ++idx)		    {		      if (len == system_dirs_len[idx]			  && memcmp (trun, cp, len) == 0)			/* Found it.  */			break;		      trun += system_dirs_len[idx] + 1;		    }		  if (idx < nsystem_dirs_len)		    /* It's a trusted directory so allow checking for it.  */		    init_val = unknown;		}	    }	  else	    /* We don't have to check for trusted directories and can	       accept everything.  We have to make sure all the	       relative directories are never ignored.  The current	       directory might change and all our saved information	       would be void.  */	    init_val = cp[0] != '/' ? existing : unknown;	  for (cnt = 0; cnt < ncapstr; ++cnt)	    dirp->status[cnt] = init_val;	  dirp->what = what;	  if (__builtin_expect (where != NULL, 1))	    dirp->where = memcpy ((char *) dirp + sizeof (*dirp) + len + 1				  + ncapstr * sizeof (enum r_dir_status),				  where, where_len);	  else	    dirp->where = NULL;	  dirp->next = _dl_all_dirs;	  _dl_all_dirs = dirp;	  /* Put it in the result array.  */	  result[nelems++] = dirp;	}    }  /* Terminate the array.  */  result[nelems] = NULL;  return result;}