pgbouncer used to store strings with final '\0', which should not be there.
It was not noticed thus far as any C clients did not saw anything wrong.
Takeover code depends on them being zero-terminated, use a hack to make them so.
if (val) {
len = strlen(val);
- pktbuf_put_uint32(buf, len + 1);
- pktbuf_put_string(buf, val);
+ pktbuf_put_uint32(buf, len);
+ pktbuf_put_bytes(buf, val, len);
} else {
/* NULL */
pktbuf_put_uint32(buf, -1);
val = NULL;
else
val = (char *)mbuf_get_bytes(pkt, len);
+
+ /* hack to zero-terminate the result */
+ if (val) {
+ val--;
+ memmove(val, val + 1, len);
+ val[len] = 0;
+ }
} else
/* tuple was shorter than requested */
val = NULL;