--format=csv: increase default buffer size

Input is percent-encoded when colon separated values mode is
enabled. Account for the percent encoding overhead (each character is
encoded as 3 characters) in the default buffer size.

Work around for message boundary bugs in csv mode, e.g.,
* only the first lihe delimited value is read: multiple lines may be in
  the buffer
* a buffer may contain a partial message
master
Michael Santos 6 months ago
parent 9ac4867fe4
commit 56424a335a

@ -89,7 +89,7 @@ int main(int argc, char **argv) {
state = xmppipe_calloc(1, sizeof(xmppipe_state_t));
xmppipe_next_state(state, XMPPIPE_S_CONNECTING);
state->bufsz = 2049;
state->bufsz = -1;
state->poll = 10;
state->keepalive = 60 * 1000;
state->keepalive_limit = 3;
@ -240,6 +240,17 @@ int main(int argc, char **argv) {
exit(2);
}
if (state->bufsz == -1) {
switch (state->format) {
case XMPPIPE_FMT_CSV:
state->bufsz = 6144 + 1;
break;
default:
state->bufsz = 2048 + 1;
break;
}
}
if (state->encode && BASE64_LENGTH(state->bufsz) + 1 > 0xffff) {
usage(state);
exit(2);

@ -85,7 +85,7 @@ typedef struct {
keepalive_fail; /* number of consecutive keepalives without a reply */
u_int32_t keepalive_limit; /* number of keepalives without a reply */
u_int32_t interval; /* time since last keepalive (milliseconds) */
size_t bufsz; /* size of read buffer */
ssize_t bufsz; /* size of read buffer */
int sm_enabled; /* stanzas: iq, message, presence */

Loading…
Cancel
Save