-------------------------------- * pq_getmsgrawstring - get a null-terminated text string - NO conversion * * Returns a pointer directly into the message buffer. * -------------------------------- */
| 607 | * -------------------------------- |
| 608 | */ |
| 609 | const char * |
| 610 | pq_getmsgrawstring(StringInfo msg) |
| 611 | { |
| 612 | char *str; |
| 613 | int slen; |
| 614 | |
| 615 | str = &msg->data[msg->cursor]; |
| 616 | |
| 617 | /* |
| 618 | * It's safe to use strlen() here because a StringInfo is guaranteed to |
| 619 | * have a trailing null byte. But check we found a null inside the |
| 620 | * message. |
| 621 | */ |
| 622 | slen = strlen(str); |
| 623 | if (msg->cursor + slen >= msg->len) |
| 624 | ereport(ERROR, |
| 625 | (errcode(ERRCODE_PROTOCOL_VIOLATION), |
| 626 | errmsg("invalid string in message"))); |
| 627 | msg->cursor += slen + 1; |
| 628 | |
| 629 | return str; |
| 630 | } |
| 631 | |
| 632 | /* -------------------------------- |
| 633 | * pq_getmsgend - verify message fully consumed |
no test coverage detected