Skip to content

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 committed Oct 2, 2019
1 parent 2bf5cc0 commit e25ca77
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 @@ -756,10 +756,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 @@ -780,7 +780,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 e25ca77

Please sign in to comment.