| 10555 | */ |
| 10556 | |
| 10557 | static |
| 10558 | char *get_41_lenc_string(char **buffer, |
| 10559 | size_t *max_bytes_available, |
| 10560 | size_t *string_length) |
| 10561 | { |
| 10562 | if (*max_bytes_available == 0) |
| 10563 | return NULL; |
| 10564 | |
| 10565 | /* Do double cast to prevent overflow from signed / unsigned conversion */ |
| 10566 | size_t str_len= (size_t)(unsigned char)**buffer; |
| 10567 | |
| 10568 | /* |
| 10569 | If the length encoded string has the length 0 |
| 10570 | the total size of the string is only one byte long (the size byte) |
| 10571 | */ |
| 10572 | if (str_len == 0) |
| 10573 | { |
| 10574 | ++*buffer; |
| 10575 | *string_length= 0; |
| 10576 | /* |
| 10577 | Return a pointer to the 0 character so the return value will be |
| 10578 | an empty string. |
| 10579 | */ |
| 10580 | return *buffer-1; |
| 10581 | } |
| 10582 | |
| 10583 | if (str_len >= *max_bytes_available) |
| 10584 | return NULL; |
| 10585 | |
| 10586 | char *str= *buffer+1; |
| 10587 | *string_length= str_len; |
| 10588 | *max_bytes_available-= *string_length + 1; |
| 10589 | *buffer+= *string_length + 1; |
| 10590 | return str; |
| 10591 | } |
| 10592 | #endif // EMBEDDED LIBRARY |
| 10593 | |
| 10594 |
nothing calls this directly
no outgoing calls
no test coverage detected