Get the integer value after rounds= where ever it occurs in the string. if the last char after the int is a , or $ that is fine anything else is an error. */
| 139 | error. |
| 140 | */ |
| 141 | static uint getrounds(const char *s) |
| 142 | { |
| 143 | const char *r; |
| 144 | const char *p; |
| 145 | char *e; |
| 146 | long val; |
| 147 | |
| 148 | if (s == NULL) |
| 149 | return (0); |
| 150 | |
| 151 | if ((r = strstr(s, ROUNDS)) == NULL) |
| 152 | { |
| 153 | return (0); |
| 154 | } |
| 155 | |
| 156 | if (strncmp(r, ROUNDS, ROUNDSLEN) != 0) |
| 157 | { |
| 158 | return (0); |
| 159 | } |
| 160 | |
| 161 | p= r + ROUNDSLEN; |
| 162 | errno= 0; |
| 163 | val= strtol(p, &e, 10); |
| 164 | /* |
| 165 | An error occurred or there is non-numeric stuff at the end |
| 166 | which isn't one of the crypt(3c) special chars ',' or '$' |
| 167 | */ |
| 168 | if (errno != 0 || val < 0 || !(*e == '\0' || *e == ',' || *e == '$')) |
| 169 | { |
| 170 | return (0); |
| 171 | } |
| 172 | |
| 173 | return ((uint32_t) val); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | Finds the interval which envelopes the user salt in a crypt password |