| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | static gid_t * | - |
| 13 | realloc_groupbuf (gid_t *g, size_t num) | - |
| 14 | { | - |
| 15 | if ((__builtin_constant_p (num) && __builtin_constant_p (sizeof *g) ? ((size_t) ( | - |
| 16 | (9223372036854775807L) | TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 17 | < | TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 18 | (18446744073709551615UL) | TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 19 | ? | TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 20 | (9223372036854775807L) | TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 21 | : | TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 22 | (18446744073709551615UL) | TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 23 | - 1) / (sizeof *g) < (num)) : ({ __xalloc_count_type __xalloc_count; __builtin_mul_overflow (num, sizeof *g, &__xalloc_count); })))| TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 24 | {| TRUE | never evaluated | | FALSE | evaluated 115 times by 1 test |
| 0-115 |
| 25 | | - |
| 26 | (*__errno_location ()) | - |
| 27 | = | - |
| 28 | 12 | - |
| 29 | ; | - |
| 30 | return | - |
| 31 | ((void *)0) never executed: ((void *)0) ; } | 0 |
| 32 | ; never executed: ((void *)0) ; } | 0 |
| 33 | } never executed: ((void *)0) ; } | 0 |
| 34 | | - |
| 35 | return realloc (g, num * sizeof *g); | - |
| 36 | } | 115 |
| 37 | int | - |
| 38 | mgetgroups (char const *username, gid_t gid, gid_t **groups) | - |
| 39 | { | - |
| 40 | int max_n_groups; | - |
| 41 | int ng; | - |
| 42 | gid_t *g; | - |
| 43 | if (username) | - |
| 44 | { | 16-42 |
| 45 | enum { N_GROUPS_INIT = 10 }; | - |
| 46 | max_n_groups = N_GROUPS_INIT; | - |
| 47 | | - |
| 48 | g = realloc_groupbuf ( | - |
| 49 | ((void *)0) | - |
| 50 | , max_n_groups); | - |
| 51 | if (g == | - |
| 52 | ((void *)0)| TRUE | never evaluated | | FALSE | evaluated 42 times by 1 test |
| 0-42 |
| 53 | )| TRUE | never evaluated | | FALSE | evaluated 42 times by 1 test |
| 0-42 |
| 54 | return -1; | - |
| 55 | | 0 |
| 56 | while (1) | - |
| 57 | { | - |
| 58 | gid_t *h; | - |
| 59 | int last_n_groups = max_n_groups; | - |
| 60 | | - |
| 61 | | - |
| 62 | ng = getgrouplist (username, gid, g, &max_n_groups); | - |
| 63 | | - |
| 64 | | - |
| 65 | | - |
| 66 | if (ng < 0 && last_n_groups == max_n_groups) | - |
| 67 | max_n_gr| TRUE | evaluated 15 times by 1 test | | FALSE | evaluated 42 times by 1 test |
oups *= 2;| TRUE | never evaluated | | FALSE | evaluated 15 times by 1 test |
| 0-42 |
| 68 | | 0 |
| 69 | if ((h = realloc_groupbuf (g, max_n_groups)) == | - |
| 70 | ((void *)0)| TRUE | never evaluated | | FALSE | evaluated 57 times by 1 test |
| 0-57 |
| 71 | )| TRUE | never evaluated | | FALSE | evaluated 57 times by 1 test |
| 0-57 |
| 72 | { | - |
| 73 | int saved_errno = | - |
| 74 | (*__errno_location ()) | - |
| 75 | ; | - |
| 76 | free (g); | - |
| 77 | | - |
| 78 | (*__errno_location ()) | - |
| 79 | = saved_errno; | - |
| 80 | return -1; | - |
| 81 | } | 0 |
| 82 | g = h; | - |
| 83 | | - |
| 84 | if (0 <= ng) | - |
| 85 | { | 15-42 |
| 86 | *groups = g; | - |
| 87 | | - |
| 88 | | - |
| 89 | return max_n_groups; | - |
| 90 | } | 42 |
| 91 | } | - |
| 92 | } | 15 |
| 93 | | 0 |
| 94 | | - |
| 95 | | - |
| 96 | max_n_groups = (username | - |
| 97 | ? getugr| TRUE | never evaluated | | FALSE | evaluated 16 times by 1 test |
oups (0, | 0-16 |
| 98 | ((void *)0) | - |
| 99 | , username, gid) | - |
| 100 | : getgroups (0, | - |
| 101 | ((void *)0) | - |
| 102 | )); | - |
| 103 | | - |
| 104 | | - |
| 105 | | - |
| 106 | | - |
| 107 | if (max_n_groups < 0) | - |
| 108 | { | 0-16 |
| 109 | if ( | - |
| 110 | (*__errno_location ()) | - |
| 111 | == | TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 112 | 38 | TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 113 | | TRUE | never evaluated | | FALSE | never evaluated |
&& (g = realloc_groupbuf ( | 0 |
| 114 | ((void *)0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 115 | , 1)))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 116 | {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 117 | *groups = g; | - |
| 118 | *g = gid; | - |
| 119 | return gid != (gid_t) -1; | - |
| 120 | } | 0 |
| 121 | return -1; | - |
| 122 | } | 0 |
| 123 | | - |
| 124 | if (max_n_groups == 0 || (!username && gid != (gid_t) -1)) | - |
| 125 | max_n_groups++;| TRUE | never evaluated | | FALSE | evaluated 16 times by 1 test |
| 0-16 |
| 126 | g =executed 16 times by 1 test: = realloc_group realloc_groupexecuted 16 times by 1 test: = realloc_group buf ( | 16 |
| 127 | ((void *)0) | - |
| 128 | , max_n_groups); | - |
| 129 | if (g == | - |
| 130 | ((void *)0)| TRUE | never evaluated | | FALSE | evaluated 16 times by 1 test |
| 0-16 |
| 131 | )| TRUE | never evaluated | | FALSE | evaluated 16 times by 1 test |
| 0-16 |
| 132 | return -1; | - |
| 133 | | 0 |
| 134 | ng = (username | - |
| 135 | ? getugr| TRUE | never evaluated | | FALSE | evaluated 16 times by 1 test |
oups (max_n_groups, g, username, gid) | 0-16 |
| 136 | : getgroups (max_n_groups - (gid != (gid_t) -1), | - |
| 137 | g + (gid != (gid_t) -1))); | - |
| 138 | | - |
| 139 | if (ng < 0) | - |
| 140 | { | 0-16 |
| 141 | | - |
| 142 | int saved_errno = | - |
| 143 | (*__errno_location ()) | - |
| 144 | ; | - |
| 145 | free (g); | - |
| 146 | | - |
| 147 | (*__errno_location ()) | - |
| 148 | = saved_errno; | - |
| 149 | return -1; | - |
| 150 | } | 0 |
| 151 | | - |
| 152 | if (!username && gid != (gid_t) -1) | - |
| 153 | { | 0-16 |
| 154 | *g = gid; | - |
| 155 | ng++; | - |
| 156 | } | - |
| 157 | *grexecuted 16 times by 1 test: r oups = g; | 16 |
| 158 | if (1 < ng) | - |
| 159 | { | 0-16 |
| 160 | gid_t first = *g; | - |
| 161 | gid_t *next; | - |
| 162 | gid_t *groups_end = g + ng; | - |
| 163 | | - |
| 164 | for (next = g + 1; next < groups_end; next++) | - |
| 165 | { | 16-176 |
| 166 | if (*next == first || *next == *g) | - |
| 167 | ng--| TRUE | evaluated 16 times by 1 test | | FALSE | evaluated 160 times by 1 test |
;| TRUE | evaluated 16 times by 1 test | | FALSE | evaluated 160 times by 1 test |
| 0-160 |
| 168 | elseexecuted 16 times by 1 test: se | 16 |
| 169 | *++g = *next; | - |
| 170 | } | 160 |
| 171 | } | - |
| 172 | | 16 |
| 173 | return ng; | - |
| 174 | } | 16 |
| | |