Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ enum {
#define SendRejNotice(x) ((x)->umodes & UMODE_REJ)
#define SendSkillNotice(x) ((x)->umodes & UMODE_SKILL)
#define SendFullNotice(x) ((x)->umodes & UMODE_FULL)
#define SendSpyNotice(x) ((x)->umodes & UMODE_SPY)1
#define SendSpyNotice(x) ((x)->umodes & UMODE_SPY)
#define SendDebugNotice(x) ((x)->umodes & UMODE_DEBUG)
#define SendNickChange(x) ((x)->umodes & UMODE_NCHANGE)
#define SetWallops(x) ((x)->umodes |= UMODE_WALLOP)
Expand Down
2 changes: 0 additions & 2 deletions libratbox/src/linebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,6 @@ rb_linebuf_get(rb_buf_head_t * bufhead, char *buf, size_t buflen, bool partial,
size_t cpylen;
char *start, *ch;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard zero-length buffers before computing copy length

Removing the buflen > 0 precondition in rb_linebuf_get allows buflen == 0 to fall through to cpylen = buflen - 1, which wraps cpylen to SIZE_MAX when there is queued data (bufline->len > 0) and then drives an out-of-bounds memcpy. Before this change, assert-enabled builds failed fast at function entry; now the same input can corrupt memory, so this path needs an explicit runtime check for zero-length destination buffers before the subtraction.

Useful? React with 👍 / 👎.

lrb_assert(buflen > 0);

/* make sure we have a line */
if(bufhead->list.head == NULL)
return 0; /* Obviously not.. hrm. */
Expand Down
2 changes: 2 additions & 0 deletions src/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,14 @@ add_connection(struct Listener *listener, rb_fde_t * F, struct sockaddr *sai, st
int saved_errno = errno;
log_listener("creating SSL/TLS socket pairs %s:%s",
get_listener_name(listener), strerror(saved_errno));
rb_close(F);
free_client(new_client);
return;
}
new_client->localClient->ssl_ctl = start_ssld_accept(F, xF[1], new_client->localClient->connid); /* this will close F for us */
if(new_client->localClient->ssl_ctl == NULL)
{
rb_close(F);
rb_close(xF[0]);
rb_close(xF[1]);
free_client(new_client);
Expand Down