* Parse digest credentials * Return value -1 means that the function was unable to allocate * memory and therefore the server should return Internal Server Error, * not Bad Request in this case ! * Bad Request should be send when return value != -1 */
| 59 | * Bad Request should be send when return value != -1 |
| 60 | */ |
| 61 | int parse_credentials(struct hdr_field* _h) |
| 62 | { |
| 63 | int res; |
| 64 | |
| 65 | if (_h->parsed) { |
| 66 | return 0; /* Already parsed */ |
| 67 | } |
| 68 | |
| 69 | if (new_credentials(_h) < 0) { |
| 70 | LM_ERR("failed to create new credentials\n"); |
| 71 | return -1; |
| 72 | } |
| 73 | |
| 74 | /* parse_digest_cred must return < -1 on error otherwise we will be |
| 75 | * unable to distinguish if the error was caused by the server or if the |
| 76 | * credentials are broken |
| 77 | */ |
| 78 | res = parse_digest_cred(&(_h->body), &(((auth_body_t*)(_h->parsed))->digest)); |
| 79 | |
| 80 | if (res != 0) { |
| 81 | free_credentials((auth_body_t**)(void*)&(_h->parsed)); |
| 82 | } |
| 83 | |
| 84 | return res; |
| 85 | } |
| 86 | |
| 87 | |
| 88 | /* |
no test coverage detected