mirror of
https://github.com/pissnet/pissircd.git
synced 2025-08-04 01:12:24 +01:00
Fix silly crash issue.
This commit is contained in:
parent
5fcff0dd90
commit
e0130ab0b6
7 changed files with 23 additions and 151 deletions
|
@ -252,7 +252,6 @@ extern void restart(char *);
|
|||
extern void server_reboot(char *);
|
||||
extern void terminate(), write_pidfile();
|
||||
extern void *MyMallocEx(size_t size);
|
||||
extern int advanced_check(char *userhost, int ipstat);
|
||||
extern int send_queued(aClient *);
|
||||
extern void sendto_connectnotice(aClient *sptr, int disconnect, char *comment);
|
||||
extern void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr, char *umodes);
|
||||
|
|
|
@ -1010,13 +1010,13 @@ CMD_FUNC(m_module)
|
|||
|
||||
tmp[0] = '\0';
|
||||
if (mi->flags & MODFLAG_DELAYED)
|
||||
strncat(tmp, "[Unloading] ", sizeof(tmp)-strlen(tmp)-1);
|
||||
strlcat(tmp, "[Unloading] ", sizeof(tmp));
|
||||
if (mi->options & MOD_OPT_PERM_RELOADABLE)
|
||||
strncat(tmp, "[PERM-BUT-RELOADABLE] ", sizeof(tmp)-strlen(tmp)-1);
|
||||
strlcat(tmp, "[PERM-BUT-RELOADABLE] ", sizeof(tmp));
|
||||
if (mi->options & MOD_OPT_PERM)
|
||||
strncat(tmp, "[PERM] ", sizeof(tmp)-strlen(tmp)-1);
|
||||
strlcat(tmp, "[PERM] ", sizeof(tmp));
|
||||
if (!(mi->options & MOD_OPT_OFFICIAL))
|
||||
strncat(tmp, "[3RD] ", sizeof(tmp)-strlen(tmp)-1);
|
||||
strlcat(tmp, "[3RD] ", sizeof(tmp));
|
||||
if (!ValidatePermissionsForPath("server:module",sptr,NULL,NULL,NULL))
|
||||
sendto_one(sptr, ":%s NOTICE %s :*** %s (%s)%s", me.name, sptr->name,
|
||||
mi->header->name, mi->header->description,
|
||||
|
|
|
@ -380,9 +380,9 @@ unsigned int alpha, n;
|
|||
ircsnprintf(result, sizeof(result), "%s-%X.", hidden_host, alpha);
|
||||
len = strlen(result) + strlen(p);
|
||||
if (len <= HOSTLEN)
|
||||
strncat(result, p, sizeof(result)-strlen(result)-1);
|
||||
strlcat(result, p, sizeof(result));
|
||||
else
|
||||
strncat(result, p + (len - HOSTLEN), sizeof(result)-strlen(result)-1);
|
||||
strlcat(result, p + (len - HOSTLEN), sizeof(result));
|
||||
} else
|
||||
ircsnprintf(result, sizeof(result), "%s-%X", hidden_host, alpha);
|
||||
|
||||
|
|
|
@ -68,8 +68,7 @@ CMD_FUNC(m_ison)
|
|||
{
|
||||
char namebuf[USERLEN + HOSTLEN + 4];
|
||||
aClient *acptr;
|
||||
char *s, **pav = parv, *user;
|
||||
int len;
|
||||
char *s, *user;
|
||||
char *p = NULL;
|
||||
|
||||
if (!MyClient(sptr))
|
||||
|
@ -83,9 +82,8 @@ CMD_FUNC(m_ison)
|
|||
}
|
||||
|
||||
ircsnprintf(buf, sizeof(buf), rpl_str(RPL_ISON), me.name, sptr->name);
|
||||
len = strlen(buf);
|
||||
|
||||
for (s = strtoken(&p, *++pav, " "); s; s = strtoken(&p, NULL, " "))
|
||||
for (s = strtoken(&p, parv[1], " "); s; s = strtoken(&p, NULL, " "))
|
||||
{
|
||||
if ((user = index(s, '!')))
|
||||
*user++ = '\0';
|
||||
|
@ -98,10 +96,8 @@ CMD_FUNC(m_ison)
|
|||
*--user = '!';
|
||||
}
|
||||
|
||||
(void)strncat(buf, s, sizeof(buf) - (len+1));
|
||||
len += strlen(s);
|
||||
(void)strncat(buf, " ", sizeof(buf) - (len+1));
|
||||
len++;
|
||||
strlcat(buf, s, sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
27
src/s_bsd.c
27
src/s_bsd.c
|
@ -165,33 +165,6 @@ void close_connections(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** add_local_domain()
|
||||
** Add the domain to hostname, if it is missing
|
||||
** (as suggested by eps@TOASTER.SFSU.EDU)
|
||||
*/
|
||||
|
||||
void add_local_domain(char *hname, int size)
|
||||
{
|
||||
#if 0
|
||||
/* try to fix up unqualified names */
|
||||
if (!index(hname, '.'))
|
||||
{
|
||||
if (!(ircd_res.options & RES_INIT))
|
||||
{
|
||||
Debug((DEBUG_DNS, "res_init()"));
|
||||
ircd_res_init();
|
||||
}
|
||||
if (ircd_res.defdname[0])
|
||||
{
|
||||
(void)strncat(hname, ".", size - 1);
|
||||
(void)strncat(hname, ircd_res.defdname, size - 2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Cannot use perror() within daemon. stderr is closed in
|
||||
** ircd and cannot be used. And, worse yet, it might have
|
||||
|
|
25
src/s_conf.c
25
src/s_conf.c
|
@ -587,7 +587,8 @@ void chmode_str(struct ChMode *modes, char *mbuf, char *pbuf, size_t mbuf_size,
|
|||
aCtab *tab;
|
||||
int i;
|
||||
|
||||
if (!(mbuf_size && pbuf_size)) return;
|
||||
if (!(mbuf_size && pbuf_size))
|
||||
return;
|
||||
|
||||
*pbuf = 0;
|
||||
*mbuf++ = '+';
|
||||
|
@ -596,13 +597,15 @@ void chmode_str(struct ChMode *modes, char *mbuf, char *pbuf, size_t mbuf_size,
|
|||
{
|
||||
if (modes->mode & tab->mode)
|
||||
{
|
||||
if (!tab->parameters) {
|
||||
if (!tab->parameters)
|
||||
{
|
||||
*mbuf++ = tab->flag;
|
||||
if (!--mbuf_size) {
|
||||
if (!--mbuf_size)
|
||||
{
|
||||
*--mbuf=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i=0; i <= Channelmode_highest; i++)
|
||||
|
@ -612,20 +615,19 @@ void chmode_str(struct ChMode *modes, char *mbuf, char *pbuf, size_t mbuf_size,
|
|||
|
||||
if (modes->extmodes & Channelmode_Table[i].mode)
|
||||
{
|
||||
if (mbuf_size) {
|
||||
if (mbuf_size)
|
||||
{
|
||||
*mbuf++ = Channelmode_Table[i].flag;
|
||||
if (!--mbuf_size) {
|
||||
if (!--mbuf_size)
|
||||
{
|
||||
*--mbuf=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Channelmode_Table[i].paracount)
|
||||
{
|
||||
strncat(pbuf, modes->extparams[i], pbuf_size-1);
|
||||
pbuf_size-=strlen(modes->extparams[i]);
|
||||
if (!pbuf_size) break;
|
||||
strncat(pbuf, " ", pbuf_size-1);
|
||||
if (!--pbuf_size) break;
|
||||
strlcat(pbuf, modes->extparams[i], pbuf_size);
|
||||
strlcat(pbuf, " ", pbuf_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2742,7 +2744,6 @@ int AllowClient(aClient *cptr, struct hostent *hp, char *sockhost, char *usernam
|
|||
{
|
||||
hname = hp->h_name;
|
||||
strlcpy(fullname, hname, sizeof(fullname));
|
||||
add_local_domain(fullname, HOSTLEN - strlen(fullname));
|
||||
Debug((DEBUG_DNS, "a_il: %s->%s", sockhost, fullname));
|
||||
if (index(aconf->hostname, '@'))
|
||||
{
|
||||
|
|
97
src/s_svs.c
97
src/s_svs.c
|
@ -44,103 +44,6 @@ extern ircstats IRCstats;
|
|||
|
||||
aConfiguration iConf;
|
||||
|
||||
/* ok, given a mask, our job is to determine
|
||||
* wether or not it's a safe mask to banish...
|
||||
*
|
||||
* userhost= mask to verify
|
||||
* ipstat= TRUE == it's an ip
|
||||
* FALSE == it's a hostname
|
||||
* UNSURE == we need to find out
|
||||
* return value
|
||||
* TRUE == mask is ok
|
||||
* FALSE == mask is not ok
|
||||
* UNSURE == [unused] something went wrong
|
||||
*/
|
||||
|
||||
int advanced_check(char *userhost, int ipstat)
|
||||
{
|
||||
register int retval = TRUE;
|
||||
char *up = NULL, *p, *thisseg;
|
||||
int numdots = 0, segno = 0, numseg, i = 0;
|
||||
char *ipseg[10 + 2];
|
||||
char safebuffer[512] = ""; /* buffer strtoken() can mess up to its heart's content...;> */
|
||||
|
||||
strlcpy(safebuffer, userhost, sizeof safebuffer);
|
||||
|
||||
#define userhost safebuffer
|
||||
#define IP_WILDS_OK(x) ((x)<2? 0 : 1)
|
||||
|
||||
if (ipstat == UNSURE)
|
||||
{
|
||||
ipstat = TRUE;
|
||||
for (; *up; up++)
|
||||
{
|
||||
if (*up == '.')
|
||||
numdots++;
|
||||
if (!isdigit(*up) && !ispunct(*up))
|
||||
{
|
||||
ipstat = FALSE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (numdots != 3)
|
||||
ipstat = FALSE;
|
||||
if (numdots < 1 || numdots > 9)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* fill in the segment set */
|
||||
{
|
||||
int l = 0;
|
||||
for (segno = 0, i = 0, thisseg = strtoken(&p, userhost, ".");
|
||||
thisseg; thisseg = strtoken(&p, NULL, "."), i++)
|
||||
{
|
||||
|
||||
l = strlen(thisseg) + 2;
|
||||
ipseg[segno] = calloc(1, l);
|
||||
strncpy(ipseg[segno++], thisseg, l);
|
||||
}
|
||||
}
|
||||
if (segno < 2 && ipstat == TRUE)
|
||||
retval = FALSE;
|
||||
numseg = segno;
|
||||
if (ipstat == TRUE)
|
||||
for (i = 0; i < numseg; i++)
|
||||
{
|
||||
if (!IP_WILDS_OK(i) && (index(ipseg[i], '*')
|
||||
|| index(ipseg[i], '?')))
|
||||
retval = FALSE;
|
||||
/* The person who wrote this function was braindead --Stskeeps */
|
||||
/* MyFree(ipseg[i]); */
|
||||
}
|
||||
else
|
||||
{
|
||||
int wildsok = 0;
|
||||
|
||||
for (i = 0; i < numseg; i++)
|
||||
{
|
||||
/* for hosts, let the mask extent all the way to
|
||||
the second-level domain... */
|
||||
wildsok = 1;
|
||||
if (i == numseg || (i + 1) == numseg)
|
||||
wildsok = 0;
|
||||
if (wildsok == 0 && (index(ipseg[i], '*')
|
||||
|| index(ipseg[i], '?')))
|
||||
{
|
||||
retval = FALSE;
|
||||
}
|
||||
/* MyFree(ipseg[i]); */
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return (retval);
|
||||
#undef userhost
|
||||
#undef IP_WILDS_OK
|
||||
|
||||
}
|
||||
|
||||
/* Function to return a group of tokens -- codemastr */
|
||||
void strrangetok(char *in, char *out, char tok, short first, short last) {
|
||||
int i = 0, tokcount = 0, j = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue