| 10494 | */ |
| 10495 | |
| 10496 | static |
| 10497 | char *get_56_lenc_string(char **buffer, |
| 10498 | size_t *max_bytes_available, |
| 10499 | size_t *string_length) |
| 10500 | { |
| 10501 | static char empty_string[1]= { '\0' }; |
| 10502 | char *begin= *buffer; |
| 10503 | |
| 10504 | if (*max_bytes_available == 0) |
| 10505 | return NULL; |
| 10506 | |
| 10507 | /* |
| 10508 | If the length encoded string has the length 0 |
| 10509 | the total size of the string is only one byte long (the size byte) |
| 10510 | */ |
| 10511 | if (*begin == 0) |
| 10512 | { |
| 10513 | *string_length= 0; |
| 10514 | --*max_bytes_available; |
| 10515 | ++*buffer; |
| 10516 | /* |
| 10517 | Return a pointer to the \0 character so the return value will be |
| 10518 | an empty string. |
| 10519 | */ |
| 10520 | return empty_string; |
| 10521 | } |
| 10522 | |
| 10523 | *string_length= (size_t)net_field_length_ll((uchar **)buffer); |
| 10524 | |
| 10525 | DBUG_EXECUTE_IF("sha256_password_scramble_too_long", |
| 10526 | *string_length= SIZE_T_MAX; |
| 10527 | ); |
| 10528 | |
| 10529 | size_t len_len= (size_t)(*buffer - begin); |
| 10530 | |
| 10531 | if (*string_length > *max_bytes_available - len_len) |
| 10532 | return NULL; |
| 10533 | |
| 10534 | *max_bytes_available -= *string_length; |
| 10535 | *max_bytes_available -= len_len; |
| 10536 | *buffer += *string_length; |
| 10537 | return (char *)(begin + len_len); |
| 10538 | } |
| 10539 | |
| 10540 | |
| 10541 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected