1 /* Failed on powerpc64-linux with a segfault due to ifcvt generating
2    conditional returns without updating dominance info.
3    Extracted from glibc's dl-load.c.  */
4 
5 typedef __SIZE_TYPE__ size_t;
6 
7 static size_t
is_dst(const char * start,const char * name,const char * str,int is_path,int secure)8 is_dst (const char *start, const char *name, const char *str,
9         int is_path, int secure)
10 {
11   size_t len;
12   _Bool is_curly = 0;
13 
14   if (name[0] == '{')
15     {
16       is_curly = 1;
17       ++name;
18     }
19 
20   len = 0;
21   while (name[len] == str[len] && name[len] != '\0')
22     ++len;
23 
24   if (is_curly)
25     {
26       if (name[len] != '}')
27         return 0;
28 
29 
30       --name;
31 
32       len += 2;
33     }
34   else if (name[len] != '\0' && name[len] != '/'
35            && (!is_path || name[len] != ':'))
36     return 0;
37 
38   if (__builtin_expect (secure, 0)
39       && ((name[len] != '\0' && (!is_path || name[len] != ':'))
40           || (name != start + 1 && (!is_path || name[-2] != ':'))))
41     return 0;
42 
43   return len;
44 }
45