Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Commit

Permalink
conn: don't hardcode buffer size
Browse files Browse the repository at this point in the history
Use sizeof instead of hardcoded size, so the buffer can be changed
easily.
  • Loading branch information
pasis authored and jubalh committed Oct 11, 2019
1 parent a313dec commit 7f8c24e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,10 @@ void xmpp_send_raw_string(xmpp_conn_t * const conn,
char *bigbuf;

va_start(ap, fmt);
len = xmpp_vsnprintf(buf, 1024, fmt, ap);
len = xmpp_vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);

if (len >= 1024) {
if (len >= sizeof(buf)) {
/* we need more space for this data, so we allocate a big
* enough buffer and print to that */
len++; /* account for trailing \0 */
Expand All @@ -786,7 +786,6 @@ void xmpp_send_raw_string(xmpp_conn_t * const conn,
xmpp_free(conn->ctx, bigbuf);
} else {
xmpp_debug(conn->ctx, "conn", "SENT: %s", buf);

xmpp_send_raw(conn, buf, len);
}
}
Expand Down

0 comments on commit 7f8c24e

Please sign in to comment.