Validate the IMSI string "IMSI"+digits; return pointer to digits or NULL if invalid.
| 319 | |
| 320 | // Validate the IMSI string "IMSI"+digits; return pointer to digits or NULL if invalid. |
| 321 | const char* extractIMSI(const char *IMSI) |
| 322 | { |
| 323 | // Form of the name is IMSI<digits>, and it should always be 18 or 19 char. |
| 324 | // IMSIs are 14 or 15 char + "IMSI" prefix |
| 325 | unsigned namelen = strlen(IMSI); |
| 326 | if (strncmp(IMSI,"IMSI",4) || (namelen>19) || (namelen<18) || !isNumeric(IMSI+4)) { |
| 327 | // Note that if you use this on a non-INVITE it will fail, because it may have fields like "222-0123" which are not IMSIs. |
| 328 | // Dont warn here. We print a better warning just once in newCheckInvite. |
| 329 | // LOG(WARNING) << "INVITE with malformed username \"" << IMSI << "\""; |
| 330 | return ""; |
| 331 | } |
| 332 | // Skip first 4 char "IMSI". |
| 333 | return IMSI+4; |
| 334 | } |
| 335 | |
| 336 | string SipMessage::smGetPrecis() const |
| 337 | { |
no test coverage detected