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
4 changes: 3 additions & 1 deletion libratbox/include/rb_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ rb_strlcat(char *dest, const char *src, size_t count)
size_t len = strlen(src);
size_t res = dsize + len;

assert(dsize >= count);

Choose a reason for hiding this comment

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

P1 Badge Fix inverted assert in rb_strlcat

The new assert(dsize >= count) is inverted: in normal, safe use of rb_strlcat, dsize is usually less than count. This assertion will therefore abort debug builds on valid inputs (e.g., when there is room in the destination buffer), while it does nothing to guard the actual overflow case (dsize >= count, which should short-circuit or return). This changes behavior from “works in release and debug” to “debug-only crash” for standard usage.

Useful? React with 👍 / 👎.


dest += dsize;
count -= dsize;
if(len >= count)
Expand Down Expand Up @@ -101,7 +103,7 @@ rb_strnlen(const char *s, size_t n)
return p;
}
#else
#define rb_strnlen(x) strnlen(x)
#define rb_strnlen(s, n) strnlen(s, n)
#endif

static inline char *
Expand Down
1 change: 0 additions & 1 deletion modules/m_topic.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ m_topic(struct Client *client_p, struct Client *source_p, int parc, const char *
{
struct Channel *chptr = NULL;
struct membership *msptr;
char *p = NULL;

if(MyClient(source_p) && !IsFloodDone(source_p))
flood_endgrace(source_p);
Expand Down