-------------------------------- * pq_getmsgstring - get a null-terminated text string (with conversion) * * May return a pointer directly into the message buffer, or a pointer * to a palloc'd conversion result. * -------------------------------- */
| 578 | * -------------------------------- |
| 579 | */ |
| 580 | const char * |
| 581 | pq_getmsgstring(StringInfo msg) |
| 582 | { |
| 583 | char *str; |
| 584 | int slen; |
| 585 | |
| 586 | str = &msg->data[msg->cursor]; |
| 587 | |
| 588 | /* |
| 589 | * It's safe to use strlen() here because a StringInfo is guaranteed to |
| 590 | * have a trailing null byte. But check we found a null inside the |
| 591 | * message. |
| 592 | */ |
| 593 | slen = strlen(str); |
| 594 | if (msg->cursor + slen >= msg->len) |
| 595 | ereport(ERROR, |
| 596 | (errcode(ERRCODE_PROTOCOL_VIOLATION), |
| 597 | errmsg("invalid string in message"))); |
| 598 | msg->cursor += slen + 1; |
| 599 | |
| 600 | return pg_client_to_server(str, slen); |
| 601 | } |
| 602 | |
| 603 | /* -------------------------------- |
| 604 | * pq_getmsgrawstring - get a null-terminated text string - NO conversion |
no test coverage detected