gcc7 fixes: NICKLEN -> NAMELEN

Use NAMELEN instead of NICKLEN when accessing Client->name because it
could in theory be a HOSTLEN length string.
This commit is contained in:
Simon Arlott 2018-01-19 23:24:55 +00:00
parent 30053ab982
commit fe5fc851aa
No known key found for this signature in database
GPG key ID: 49BFFEEFD4C3ED53
8 changed files with 24 additions and 22 deletions

View file

@ -32,10 +32,10 @@ _moddeinit(void)
static int
eb_hostmask(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type)
{
char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
char src_ip4host[NICKLEN + USERLEN + HOSTLEN + 6];
char src_host[NAMELEN + USERLEN + HOSTLEN + 6];
char src_iphost[NAMELEN + USERLEN + HOSTLEN + 6];
char src_althost[NAMELEN + USERLEN + HOSTLEN + 6];
char src_ip4host[NAMELEN + USERLEN + HOSTLEN + 6];
struct sockaddr_in ip4;
char *s = src_host, *s2 = src_iphost, *s3 = NULL, *s4 = NULL;

View file

@ -126,7 +126,7 @@ struct Client
unsigned long serial; /* used to enforce 1 send per nick */
/* client->name is the unique name for a client nick or host */
char name[HOSTLEN + 1];
char name[NAMELEN + 1];
/*
* client->username is the username from ident or the USER message,

View file

@ -97,7 +97,9 @@
#define EXT_BUFSIZE (TAGSLEN + DATALEN + 1)
#define OPERNICKLEN (NICKLEN*2) /* Length of OPERNICKs. */
#define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5)
#define NAMELEN (MAX(NICKLEN, HOSTLEN))
#define USERHOST_REPLYLEN (NAMELEN+HOSTLEN+USERLEN+5)
#define MAX_DATE_STRING 32 /* maximum string length for a date string */
#define HELPLEN 400

View file

@ -539,10 +539,10 @@ is_banned_list(struct Channel *chptr, rb_dlink_list *list,
struct Client *who, struct membership *msptr,
const char *s, const char *s2, const char **forward)
{
char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
char src_ip4host[NICKLEN + USERLEN + HOSTLEN + 6];
char src_host[NAMELEN + USERLEN + HOSTLEN + 6];
char src_iphost[NAMELEN + USERLEN + HOSTLEN + 6];
char src_althost[NAMELEN + USERLEN + HOSTLEN + 6];
char src_ip4host[NAMELEN + USERLEN + HOSTLEN + 6];
char *s3 = NULL;
char *s4 = NULL;
struct sockaddr_in ip4;
@ -722,9 +722,9 @@ can_join(struct Client *source_p, struct Channel *chptr, const char *key, const
rb_dlink_node *invite = NULL;
rb_dlink_node *ptr;
struct Ban *invex = NULL;
char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
char src_host[NAMELEN + USERLEN + HOSTLEN + 6];
char src_iphost[NAMELEN + USERLEN + HOSTLEN + 6];
char src_althost[NAMELEN + USERLEN + HOSTLEN + 6];
int use_althost = 0;
int i = 0;
hook_data_channel moduledata;
@ -964,8 +964,8 @@ find_bannickchange_channel(struct Client *client_p)
struct Channel *chptr;
struct membership *msptr;
rb_dlink_node *ptr;
char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
char src_host[NAMELEN + USERLEN + HOSTLEN + 6];
char src_iphost[NAMELEN + USERLEN + HOSTLEN + 6];
if (!MyClient(client_p))
return NULL;

View file

@ -1261,7 +1261,7 @@ char *
get_oper_name(struct Client *client_p)
{
/* +5 for !,@,{,} and null */
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
static char buffer[NAMELEN + USERLEN + HOSTLEN + HOSTLEN + 5];
if(MyOper(client_p))
{

View file

@ -414,13 +414,13 @@ register_local_user(struct Client *client_p, struct Client *source_p)
/* Apply nick override */
if(*source_p->preClient->spoofnick)
{
char note[NICKLEN + 10];
char note[NAMELEN + 10];
del_from_client_hash(source_p->name, source_p);
rb_strlcpy(source_p->name, source_p->preClient->spoofnick, NICKLEN + 1);
add_to_client_hash(source_p->name, source_p);
snprintf(note, NICKLEN + 10, "Nick: %s", source_p->name);
snprintf(note, sizeof(note), "Nick: %s", source_p->name);
rb_note(source_p->localClient->F, note);
}

View file

@ -160,7 +160,7 @@ me_rsfnc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
struct Client *target_p;
struct Client *exist_p;
time_t newts, curts;
char note[NICKLEN + 10];
char note[NAMELEN + 10];
if(!(source_p->flags & FLAGS_SERVICE))
{
@ -252,7 +252,7 @@ doit:
del_all_accepts(target_p);
snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
snprintf(note, sizeof(note), "Nick: %s", target_p->name);
rb_note(target_p->localClient->F, note);
}

View file

@ -233,11 +233,11 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
}
else
{
char note[NICKLEN + 10];
char note[NAMELEN + 10];
send_signon(NULL, target_p, nick, user, host, rb_current_time(), login);
snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
snprintf(note, sizeof(note), "Nick: %s", target_p->name);
rb_note(target_p->localClient->F, note);
}
}